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
60
Grid inside xamdatatree
posted

Hi, how can i do something like this: in the last level of my tree i want to put an grid, like

A
   B
       GRID
   C
       D
          GRID

A,B,C and D all got an list inside named subitems and values. To build the tree i get data from subitems and to fill the grid i need to use data from values

 

  • 21382
    posted

    There isn't anything in the XamDataTree that will do this natively.  You might be able to get some results if you  your item template with two elements, the grid and a textblock that shows your display text

                 <ig:NodeLayout Key="layout1" TargetTypeName="Person" DisplayMemberPath="Name" >
                        <ig:NodeLayout.ItemTemplate>
                            <DataTemplate>
                                <StackPanel>
                                <TextBlock Text="{Binding Data.Name}" Visibility="{Binding Converter={StaticResource tbConv}}" ></TextBlock>
                                    <ig:XamGrid ItemsSource="{Binding Data.SubNames}" Visibility="{Binding Converter={StaticResource gridConv}}" ></ig:XamGrid>
                                </StackPanel>
                            </DataTemplate>
                        </ig:NodeLayout.ItemTemplate>
                    </ig:NodeLayout>

     

    Then have ValueConverters on the visibility property of the two objects and turn them on and off depending on if you have children nodes or not.

     

        public class TextblockConverter : IValueConverter
        {
            #region IValueConverter Members
    
            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                XamDataTreeNodeDataContext context = value as XamDataTreeNodeDataContext;
                if (context != null)
                {
                    Person p = context.Data as Person;
    
                    if (p != null)
                    {
                        return p.Children != null && p.Children.Count > 0 ? Visibility.Visible : Visibility.Collapsed ;
                    }
                }
                return Visibility.Visible;
            }
    
            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                throw new NotImplementedException();
            }
    
            #endregion
        }