Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1585
Set XamTreeItem IsExpanded when using a Template
posted

Here is my code for my XamTree. I am currently setting the IsExpanded attribute programatically so the tree is ALWAYS expanded. Is there a way to set IsExpanded in my template as shown below, so I dont have to do it programatically?

 

<igTree:XamTree ItemsSource="{Binding Path=Nodes}"
                   Margin="0,0"
                   Padding="0,0"
                   BorderBrush="#FF96B3DD"
                   Background="#FFFFFFFF"
               
                   >
  <igTree:XamTree.HierarchicalItemTemplate>
    <ig:HierarchicalDataTemplate ItemsSource="{Binding Path=Children}" >
      <DataTemplate>
        <StackPanel Orientation="Horizontal">
          <Image Source="{Binding ImageUrl}" />
          <HyperlinkButton
                  Content='{Binding ItemName}'
                  HorizontalAlignment='Left'
                  VerticalAlignment='Top'
                  Command="{Binding PostbackCommand}"
                  CommandParameter="{Binding UUID}"
                  Margin="2,0"
                  Foreground="Black"
                  IsTabStop="False">
          </HyperlinkButton>
        </StackPanel>
      </DataTemplate>
      <ig:HierarchicalDataTemplate.HierarchicalItemTemplate>
        <ig:HierarchicalDataTemplate ItemsSource="{Binding Path=Children}">
          <!-- Second Level -->
          <DataTemplate>
            <StackPanel Orientation="Horizontal">
              <Image Source="{Binding ImageUrl}" />
              <HyperlinkButton
                      Content='{Binding ItemName}'
                      HorizontalAlignment='Left'
                      VerticalAlignment='Top'
                      Command="{Binding PostbackCommand}"
                      CommandParameter="{Binding UUID}"
                      Margin="2,0"
                      Foreground="Black"
                      IsTabStop="False">
              </HyperlinkButton>
            </StackPanel>
          </DataTemplate>
          <ig:HierarchicalDataTemplate.HierarchicalItemTemplate>
            <ig:HierarchicalDataTemplate ItemsSource="{Binding Path=Children}">
              <!-- Third Level -->
              <DataTemplate>
                <StackPanel Orientation="Horizontal">
                  <Image Source="{Binding ImageUrl}" />
                  <HyperlinkButton
                          Content='{Binding ItemName}'
                          HorizontalAlignment='Left'
                          VerticalAlignment='Top'
                          Command="{Binding PostbackCommand}"
                          CommandParameter="{Binding UUID}"
                          Margin="2,0"
                          Foreground="Black"
                          IsTabStop="False">
                  </HyperlinkButton>
                </StackPanel>
              </DataTemplate>
            </ig:HierarchicalDataTemplate>
          </ig:HierarchicalDataTemplate.HierarchicalItemTemplate>
        </ig:HierarchicalDataTemplate>
      </ig:HierarchicalDataTemplate.HierarchicalItemTemplate>
    </ig:HierarchicalDataTemplate>
  </igTree:XamTree.HierarchicalItemTemplate>
</igTree:XamTree>

  • 21382
    Verified Answer
    posted

    You can change the ItemContainerStyle and set the IsExpanded there:

     

        <UserControl.Resources>

            <Style TargetType="ig:XamTreeItem" x:Name="ExpandNodes">

                <Setter Property="IsExpanded" Value="true"></Setter>

            </Style>

        </UserControl.Resources>

     

     <ig:XamTree x:Name="tree" ItemContainerStyle="{StaticResource ExpandNodes}" >

    ....

    </ig:XamTree>