Click here to Skip to main content
16,008,299 members
Home / Discussions / WPF
   

WPF

 
QuestionExecuting an animation from within code? Pin
Red_Wizard_Shot_The_Food3-Apr-08 5:48
Red_Wizard_Shot_The_Food3-Apr-08 5:48 
AnswerRe: Executing an animation from within code? Pin
User 2710093-Apr-08 5:57
User 2710093-Apr-08 5:57 
GeneralWPF Dependancy Property issue Pin
riddle20002-Apr-08 23:01
riddle20002-Apr-08 23:01 
GeneralRe: WPF Dependancy Property issue Pin
Pete O'Hanlon3-Apr-08 1:25
mvePete O'Hanlon3-Apr-08 1:25 
GeneralRe: WPF Dependancy Property issue Pin
User 2710093-Apr-08 3:50
User 2710093-Apr-08 3:50 
GeneralRe: WPF Dependancy Property issue Pin
Insincere Dave3-Apr-08 6:02
Insincere Dave3-Apr-08 6:02 
GeneralRe: WPF Dependancy Property issue Pin
riddle20007-Apr-08 22:56
riddle20007-Apr-08 22:56 
QuestionIs WPF TreeView binding supposed to work like this (no collapse triangle)? [modified] Pin
artwallacex2-Apr-08 22:44
artwallacex2-Apr-08 22:44 
Hi,
I hope someone can help me understand what is going on with WPF TreeView binding.

My project has been having some weird issues with treeviews bound to a recursively created collection. The problem is that some nodes haven't had an expander/collapser triangle even though they still have subnodes (they can be doubleclicked to expand/collapse though).

Here are two small pictures of the issue I'm having:
http://www.crankedup.com/misc/wpf-treeview-notriangle.png[^]
http://www.crankedup.com/misc/wpf-treeview-notriangle2.png[^]
The second pic is the expanded version of the first one.

The code that created this is:
TreeNode tn1 = new TreeNode(@"C:\");<br />
TreeNode tn2 = new TreeNode(@"C:\");<br />
TreeNode tn3 = new TreeNode(@"C:\");<br />
<br />
TreeNodeList.Add(tn1); // Produces item with no expander!<br />
<br />
tn1.Children.Add(tn2);<br />
tn1.Children.Add(tn3);<br />
<br />
TreeNodeList.Add(tn1); // Works fine


The treenode class is the standard stuff:
public class TreeNode<br />
{<br />
    private string dir = "";<br />
    private List<treenode> children = new List<treenode>();<br />
    public TreeNode(string directory)<br />
    {<br />
        dir = directory;<br />
    }<br />
    public string Dir<br />
    {<br />
        get { return dir; }<br />
        set { dir = value; }<br />
    }<br />
    public List<treenode> Children<br />
    {<br />
        get { return children; }<br />
        set { children = value; }<br />
    }<br />
}


And the XAML binding was taken from examples I've seen on the web:
    <Window.Resources><br />
        <HierarchicalDataTemplate DataType="{x:Type local:TreeNode}" ItemsSource="{Binding Path=Children}"><br />
            <StackPanel Orientation="Horizontal"><br />
                <Image Source="Graphics\folder.png" /><br />
                <TextBlock Text="{Binding Path=Dir}" Margin="5,0" /><br />
            </StackPanel><br />
        </HierarchicalDataTemplate><br />
    </Window.Resources><br />
<br />
    <TreeView HorizontalAlignment="Left" Margin="8,9,0,38" Name="treeView1" Width="188" ItemsSource="{x:Static local:Window1.TreeNodeList}" />


What am I doing wrong here?

modified on Thursday, April 3, 2008 4:50 AM

GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
User 2710093-Apr-08 3:54
User 2710093-Apr-08 3:54 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
artwallacex3-Apr-08 5:43
artwallacex3-Apr-08 5:43 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
User 2710093-Apr-08 5:51
User 2710093-Apr-08 5:51 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
artwallacex3-Apr-08 6:06
artwallacex3-Apr-08 6:06 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
User 2710093-Apr-08 6:10
User 2710093-Apr-08 6:10 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? [modified] Pin
artwallacex3-Apr-08 6:14
artwallacex3-Apr-08 6:14 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
User 2710093-Apr-08 6:33
User 2710093-Apr-08 6:33 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
artwallacex3-Apr-08 6:47
artwallacex3-Apr-08 6:47 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
User 2710093-Apr-08 6:57
User 2710093-Apr-08 6:57 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Pin
artwallacex3-Apr-08 7:06
artwallacex3-Apr-08 7:06 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Found the solution Pin
User 2710093-Apr-08 7:30
User 2710093-Apr-08 7:30 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Found the solution [modified] Pin
artwallacex3-Apr-08 7:42
artwallacex3-Apr-08 7:42 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Found the solution Pin
User 2710093-Apr-08 7:44
User 2710093-Apr-08 7:44 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Found the solution Pin
artwallacex3-Apr-08 8:00
artwallacex3-Apr-08 8:00 
GeneralRe: Is WPF TreeView binding supposed to work like this (no collapse triangle)? Found the solution Pin
User 2710093-Apr-08 8:07
User 2710093-Apr-08 8:07 
QuestionTable like control to set width in percentages Pin
djdajo2-Apr-08 22:13
djdajo2-Apr-08 22:13 
GeneralRe: Table like control to set width in percentages Pin
artwallacex2-Apr-08 22:49
artwallacex2-Apr-08 22:49 

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.