Checking/unchecking a tree node doesn't check/uncheck its child nodes automatically?

7 posts, 0 answers
  1. Arpit
    Arpit avatar
    49 posts
    Member since:
    Nov 2010

    Posted 29 May 2011 Link to this post

    Hi,
    I am using a treeview in tri state mode. Initially the treeview is is collapsed mode. When I click and check on a collapsed parent node, its child nodes never gets checked automatically.
    Once the parent node is expanded (and even if its collapsed then) and I check this node, its children are checked properly.

    My requirement is to have all the nodes initially collapsed to parent level, when I check/uncheck a parent node, the node should expand and its children should get checked automatically.

    Here is my markup for the treeview
    <telerikNavigation:RadTreeView  Grid.Column="0" Grid.Row="0" x:Name="rdTreeView" ItemsOptionListType="CheckList" DockPanel.Dock="Bottom"
                        IsOptionElementsEnabled="True" IsRootLinesEnabled="True"  VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                        IsTriStateMode="True" Telerik:StyleManager.Theme="Office_Blue"
                        IsLineEnabled="True" IsEditable="True" Background="White" Margin="0,0,0,0" SelectionMode="Single"
                        IsExpandOnSingleClickEnabled="True" IsExpandOnDblClickEnabled="False"
                       BringIntoViewMode="HeaderAndItems" ItemContainerStyle="{StaticResource ItemContainerStyle}"
                        IsLoadOnDemandEnabled="False" IsVirtualizing="True"  telerikTreeView:TreeViewPanel.VirtualizationMode="Hierarchical"
                        Checked="rdTreeView_Checked" Unchecked="rdTreeView_Unchecked">
                        </telerikNavigation:RadTreeView>


    Is there something I am missing? Please help.

    Thanks
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 01 Jun 2011 Link to this post

    Hello Arpit,

    From the code snippet you sent I am not sure whether you bind the RadTreeViewItem.IsChecked or RadTreeViewItem.CheckState property. If you do, then you need to keep in mind that in binding scenarios the binding takes precedence over the TriState logic. This means that if the RadTreeViewItem.IsChecked/CheckState property binding sets the IsChecked/CheckState property to false/Off, the RadTreeView TriState logic won't change the value set by the binding.

    If this is your case, it would be better to implement a custom TriState logic in your view models. I attached a sample application demonstrating a possible approach towards such scenario.

    Greetings,
    Tina Stancheva
    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Arpit
    Arpit avatar
    49 posts
    Member since:
    Nov 2010

    Posted 03 Jun 2011 Link to this post

    I am using CheckedState property of the treeview nodes. The children nodes get checked/unchecked if they are expanded (it means if they are in view) not other wise.
    <Style TargetType="{x:Type telerikNavigation:RadTreeViewItem}" x:Key="ItemContainerStyle">
                    <Setter Property="IsExpanded" Value="{Binding Path=Expanded, Mode=TwoWay}"/>
                    <Setter Property="CheckState" Value="{Binding Path=ToggleState, Mode=TwoWay}"/>
                </Style>
  5. Arpit
    Arpit avatar
    49 posts
    Member since:
    Nov 2010

    Posted 03 Jun 2011 Link to this post

    This is urgent for me, if somebody can respond quickly on this, it will be a great help.
  6. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 03 Jun 2011 Link to this post

    Hi Arpit,

    Thank you for the clarification. Indeed when you bind the CheckState property of the RadTreeViewItems the TriStateMode of the RadTreeView control won't work since the binding has a higher priority. That means that if you initially set all RadTreeViewItems CheckState to Off, then even if the RadTreeView.TriStateMode is turned on and you check a parent, this will only change the value of the parent's ToggleState business property, however since the binding logic is with a higher priority, this action will not trigger any changes in the ToggleState business properties of the parent's children collection.

    This is a design decision in the RadTreeView control since when you bind the RadTreeView control states, then the ViewModel should control them and letting the RadTreeView.TriStateMode change the ViewModel properties might cause many issues. This is why above (TreeViewCustomTriState.zip) I attached a sample project that demonstrates how to implement a tri-state logic in the ViewModel. Please examine the project and let me know if it helps.

    Greetings,
    Tina Stancheva
    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
  7. Arpit
    Arpit avatar
    49 posts
    Member since:
    Nov 2010

    Posted 03 Jun 2011 Link to this post

    Thanks for the response Tina,

    I am not using view model pattern in my application, so couldn't use the solution you sent. Another problem I am facing is PreviewChecked and PreviewUnchecked events of tree run multiple time for e.IsUserInitiated == true for the same node.

    These issues are really disappointing at this moment.
  8. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 08 Jun 2011 Link to this post

    Hi Arpit,

    I am really sorry to hear about your frustration and I want to assure you that we want to facilitate your efforts when using the RadTreeView control in your scenario. However, I am not sure that I understand the specifications of your scenario. Can you please send us a sample project illustrating your scenario and requirements so that we can look into it and provide you with a better solution for your issues.

    Also, I wasn't able to reproduce the PreviewChecked and PreviewUnchecked events issue you reproted so a sample project will also help us investigate that case as well.

    Thank you in advance for your understanding and cooperation.

    Best wishes,
    Tina Stancheva
    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
Back to Top
UI for WPF is Visual Studio 2017 Ready