This is a migrated thread and some comments may be shown as answers.

RadTreeListViewItem?

5 Answers 433 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Corey
Top achievements
Rank 1
Corey asked on 01 Nov 2010, 08:09 PM
Are there any plans to incorporate the RadTreeListViewItem class from SL into WPF? I could really use this functionality. In the meantime, if anybody know how to quickly implement tri-state checking using the current RadTreeListView I'd like to see your code.

Thanks,

Corey

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 02 Nov 2010, 08:12 AM
Hello Corey,

 Our TreeListView is available for both Silverlight and WPF:
http://www.telerik.com/help/wpf/radtreelistview-overview.html
http://www.telerik.com/help/silverlight/radtreelistview-overview.html

Regards,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Corey
Top achievements
Rank 1
answered on 02 Nov 2010, 06:20 PM
Indeed, it is, and I'm putting it to good work. It is a very impressive control. Perhaps I did not construct my initial question very well. Currently, in the WPF RadTreeListView I'm trying to implement tri-state checking, however, I'm unable to locate the "RadTreeListViewItem" for referencing/building a style to allow me to do tri-state checking with the WPF control.

In addition to this I've noticed that with the default CheckboxColumn I have to click three time to get my checkbox to be checked. The first time seems to select the row, the second seems to select the column, and the third checks the box. Anyone else noticed this behavior?

Thanks,

Corey
0
Accepted
Vlad
Telerik team
answered on 03 Nov 2010, 07:57 AM
Hello Corey,

 We have TreeListViewRow not RadTreeListViewItem. You can try also GridViewSelectColumn instead check box column if you want selection. The check box column is related to editing of boolean values. 

Best wishes,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Corey
Top achievements
Rank 1
answered on 04 Nov 2010, 02:37 AM
I've attached sample code below that displays some of the difficulty I'm having with the two proposed solutions. Any feedback is appreciated. Please see Window1.

namespace GridViewSelectColumn.ViewModel {
    public class TreeRowViewModel : ObservableObject {
        public TreeRowViewModel() {           
        }
 
        private TreeRowViewModel parent;
        public TreeRowViewModel Parent {
            get { return parent; }
            set {
                parent = value;
                RaisePropertyChanged("Parent");
            }
        }
 
        private string name;
        public string Name {
            get { return name; }
            set {
                name = value;
                RaisePropertyChanged("Name");
            }
        }
 
        private ObservableCollection<TreeRowViewModel> children;
        public ObservableCollection<TreeRowViewModel> Children {
            get {
                return children;
            }
            set {
                children = value;
                RaisePropertyChanged("Children");
            }
        }       
 
        private bool isSelected;
        public bool IsSelected {
            get { return isSelected; }
            set {
                isSelected = value;
                RaisePropertyChanged("IsSelected");
 
                Action<TreeRowViewModel> childRun = null;
                childRun = (n) => {
                    if (n.GetHashCode() != this.GetHashCode()) {
                        n.SetIsSelected(this.isSelected);
                    }
 
                    if (n.Children != null) {
                        n.Children.ToList().ForEach(childRun);
                    }
                };
 
                childRun.Invoke(this);
 
                SetParentIsSelected(isSelected);
            }
        }
 
        public void SetIsSelected(bool s) {
            isSelected = s;
            RaisePropertyChanged("IsSelected");
        }
 
        public void SetParentIsSelected(bool s) {           
            if (Parent != null) {
                Parent.SetIsSelected(s);
                Parent.SetParentIsSelected(s);
            }
        }
    }
}

namespace GridViewSelectColumn.ViewModel {   
    public class TreeViewModel : ObservableObject {
        public TreeViewModel() {
            var top = new TreeRowViewModel {
                Name = "Top level",
                Parent = null,
                IsSelected = false,
                Children = new ObservableCollection<TreeRowViewModel>()
            };
 
            var second = new TreeRowViewModel {
                Name = "Second level",
                Parent = top,
                IsSelected = false,
                Children = new ObservableCollection<TreeRowViewModel>()
            };
 
            top.Children.Add(second);
             
            RootItems = new ObservableCollection<TreeRowViewModel> {
                top
            };
        }
 
        private ObservableCollection<TreeRowViewModel> rootItems;
        public ObservableCollection<TreeRowViewModel> RootItems {
            get { return rootItems; }
            set {
                rootItems = value;
                RaisePropertyChanged("RootItems");
            }
        }
 
        private TreeRowViewModel selection;
        public TreeRowViewModel Selection {
            get { return selection; }
            set {
                selection = value;
                RaisePropertyChanged("Selection");            
            }
        }
    }
}

<Window x:Class="GridViewSelectColumn.GridViewCheckBoxColumnView"
    xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls.TreeListView;assembly=Telerik.Windows.Controls.GridView"
    Title="GridViewCheckBoxColumn" Height="300" Width="300">
    <Grid>
        <telerik:RadTreeListView
                        HorizontalAlignment="Stretch"
                        Name="radTreeListView"
                        AutoGenerateColumns="False"                       
                        SelectionMode="Extended"    
                        SelectionUnit="FullRow"                                                   
                        ItemsSource="{Binding RootItems}">
            <telerik:RadTreeListView.ChildTableDefinitions>
                <telerik:TreeListViewTableDefinition ItemsSource="{Binding Children}" />
            </telerik:RadTreeListView.ChildTableDefinitions>
 
            <telerik:RadTreeListView.Columns>
                <telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding IsSelected, Mode=TwoWay}" AutoSelectOnEdit="True" Header="" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" />
            </telerik:RadTreeListView.Columns>
        </telerik:RadTreeListView>
    </Grid>
</Window>

<Window x:Class="GridViewSelectColumn.GridViewSelectColumnView"
    xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls.TreeListView;assembly=Telerik.Windows.Controls.GridView"
    Title="GridViewSelectColumn" Height="300" Width="300">
    <Window.Resources>
        <Style TargetType="{x:Type telerikGridView:TreeListViewRow}">
            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
        </Style>
    </Window.Resources>
    <Grid>
        <telerik:RadTreeListView
                        HorizontalAlignment="Stretch"
                        Name="radTreeListView"
                        AutoGenerateColumns="False"                       
                        SelectionMode="Extended"    
                        SelectionUnit="FullRow"                                                   
                        ItemsSource="{Binding RootItems}">
            <telerik:RadTreeListView.ChildTableDefinitions>
                <telerik:TreeListViewTableDefinition ItemsSource="{Binding Children}" />
            </telerik:RadTreeListView.ChildTableDefinitions>
 
            <telerik:RadTreeListView.Columns>
                <telerik:GridViewSelectColumn Header="" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" />
            </telerik:RadTreeListView.Columns>
        </telerik:RadTreeListView>
    </Grid>
</Window>

<Window x:Class="GridViewSelectColumn.Window1"
    Title="Window1" Height="300" Width="680">   
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Button Grid.Row="0" Click="Button_Click" Content="Select column" Height="50" Width="142" />
        <TextBlock Grid.Row="1" TextWrapping="Wrap">
            Notice in the Select sample you can select the first row and it will properly check/select the second row.
            However, if you click another column in the first or second row it will deselect both.
            Another problem here is that this is completely based on selection. What if I want to check the box
            but not require that the row itself is selected? This seems to couple checking /w selection...
        </TextBlock>
        <Button Grid.Row="2" Click="Button_Click_1" Content="CheckBox column" Height="50" Width="142" />
        <TextBlock Grid.Row="3" TextWrapping="Wrap">
            Notice in the CheckBox sample that you have to click twice to check a box. Then, despite the viewmodel for the second row being updated the check box
            in the second row appears unchanged.
        </TextBlock>
    </Grid>
</Window>


Thanks,

Corey
0
Corey
Top achievements
Rank 1
answered on 04 Nov 2010, 04:00 PM
Setting CanUserSelect="False" on the RadTreeListView gets the "Select sample" much, much closer to what I'm striving for.

Thanks,

Corey
Tags
TreeListView
Asked by
Corey
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Corey
Top achievements
Rank 1
Share this question
or