Click here to Skip to main content
15,881,715 members
Home / Discussions / WPF
   

WPF

 
QuestionBest Practice for using WPF Resources Pin
hari111r19-May-14 19:14
hari111r19-May-14 19:14 
AnswerRe: Best Practice for using WPF Resources Pin
Mycroft Holmes19-May-14 21:22
professionalMycroft Holmes19-May-14 21:22 
GeneralRe: Best Practice for using WPF Resources Pin
hari111r19-May-14 23:52
hari111r19-May-14 23:52 
GeneralRe: Best Practice for using WPF Resources Pin
Mycroft Holmes20-May-14 13:02
professionalMycroft Holmes20-May-14 13:02 
QuestionTwo questions about the TreeView control Pin
Mc_Topaz16-May-14 1:45
Mc_Topaz16-May-14 1:45 
AnswerRe: Two questions about the TreeView control Pin
SledgeHammer0116-May-14 6:45
SledgeHammer0116-May-14 6:45 
QuestionRe: Two questions about the TreeView control Pin
Mc_Topaz16-May-14 7:40
Mc_Topaz16-May-14 7:40 
AnswerRe: Two questions about the TreeView control Pin
SledgeHammer0116-May-14 8:16
SledgeHammer0116-May-14 8:16 
The way you have it set up above, you'll only be able to control the IsExpanded "once" (at creation of the node). I.e. create a node expanded. If that is not sufficient and you need to be able to expand and collapse at will, you'll need to go a slightly different route. It is more complicated, so I won't go into that unless you need it Smile | :) .

Yes, you will need to slightly modify your XAML (assuming your namespace is local):

<local:HierarchialDataTemplateEx IsExpanded="True" ... >
</local:HierarchialDataTemplateEx>

In your ValidateTemplateParent() method, you just do something like:

base.ValidateTemplatedParent(templatedParent);

// set the properties on the TreeViewItem

if ((object)templatedParent != null)
{
TreeViewItem tvi = templatedParent.TemplatedParent as TreeViewItem;

if ((object)tvi != null)
tvi.IsExpanded = IsExpanded;

That should be sufficient for most use cases (creating a node in its expanded state). As I mentioned above, you need to do additional stuff if you need to control expansion state dynamically or get the node expansion state at runtime for saving expansion state, etc.

However, this basic way will let you for example create the top level expanded and the rest of the levels collapsed.
GeneralRe: Two questions about the TreeView control Pin
Mc_Topaz16-May-14 9:08
Mc_Topaz16-May-14 9:08 
QuestionOCR using Microsoft Office Document Imaging 12.0 Type Library in WPF application Pin
Member 785476914-May-14 20:20
Member 785476914-May-14 20:20 
AnswerRe: OCR using Microsoft Office Document Imaging 12.0 Type Library in WPF application Pin
AlphaDeltaTheta15-May-14 16:48
AlphaDeltaTheta15-May-14 16:48 
QuestionSilverlight: Exception with ListBox and nested collection Pin
tongo7612-May-14 23:01
tongo7612-May-14 23:01 
AnswerRe: Silverlight: Exception with ListBox and nested collection Pin
Mycroft Holmes13-May-14 12:56
professionalMycroft Holmes13-May-14 12:56 
QuestionWPF Generate Dynamic Messages Including Links Pin
Kevin Marois6-May-14 16:44
professionalKevin Marois6-May-14 16:44 
AnswerRe: WPF Generate Dynamic Messages Including Links Pin
Bernhard Hiller6-May-14 20:58
Bernhard Hiller6-May-14 20:58 
QuestionCreating multilanguage WPF MVVM application Pin
sifi mohamed amine2-May-14 4:43
sifi mohamed amine2-May-14 4:43 
QuestionMultiBinding Question Pin
Kevin Marois1-May-14 14:32
professionalKevin Marois1-May-14 14:32 
QuestionUpdate Instance Property From DP Pin
Kevin Marois29-Apr-14 6:29
professionalKevin Marois29-Apr-14 6:29 
AnswerRe: Update Instance Property From DP Pin
Richard Deeming29-Apr-14 6:34
mveRichard Deeming29-Apr-14 6:34 
GeneralRe: Update Instance Property From DP Pin
Kevin Marois29-Apr-14 6:37
professionalKevin Marois29-Apr-14 6:37 
QuestionWPF Style Question Pin
Kevin Marois28-Apr-14 7:18
professionalKevin Marois28-Apr-14 7:18 
AnswerRe: WPF Style Question Pin
Pete O'Hanlon28-Apr-14 7:24
mvePete O'Hanlon28-Apr-14 7:24 
GeneralRe: WPF Style Question Pin
Kevin Marois28-Apr-14 7:27
professionalKevin Marois28-Apr-14 7:27 
GeneralRe: WPF Style Question Pin
Pete O'Hanlon28-Apr-14 8:09
mvePete O'Hanlon28-Apr-14 8:09 
AnswerRe: WPF Style Question Pin
pradeep surya10-May-14 5:37
pradeep surya10-May-14 5:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.