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

LoadOnDemand changing CheckState

1 Answer 65 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Drew
Top achievements
Rank 1
Drew asked on 25 Aug 2011, 08:55 PM
I have created the following RadTreeView:


<Style TargetType="telerik:RadTreeViewItem" x:Key="RadTreeViewItemStyle">
    <Setter Property="CheckState" Value="{Binding Path=CheckState, Mode=TwoWay, Converter={StaticResource ToggleStateToBoolean}}" />
    <Setter Property="DefaultImageSrc" Value="{Binding ListImage}" />
    <Setter Property="IsExpanded" Value="{Binding IsExpanded}" />
    <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
</Style>
<HierarchicalDataTemplate x:Key="TreeViewItemTemplate" ItemsSource="{Binding DirectoryList}" ItemContainerStyle="{StaticResource RadTreeViewItemStyle}">
    <TextBlock Text="{Binding DisplayName}"  Margin="0,0,5,0"/>
</HierarchicalDataTemplate>
  
        <telerik:RadTreeView Grid.Column="0" IsLineEnabled="True" ItemsOptionListType="CheckList" IsOptionElementsEnabled="True" IsTriStateMode="True"
                             BorderBrush="Black" BorderThickness="1" ItemsSource="{Binding RootItems}" ItemTemplate="{StaticResource TreeViewItemTemplate}"
                             IsLoadOnDemandEnabled="True" LoadOnDemand="RadTreeView_LoadOnDemand" ItemContainerStyle="{StaticResource RadTreeViewItemStyle}"
                             Background="White" Name="ExplorerTree">
        </telerik:RadTreeView>

In the codebehind, I am passing the LoadOnDemand back to my viewmodel for processing.  Everything is working exactly as it should except for when I attempt to load a node that has been selected.  If I select the node and then fire the LoadOnDemand event, it loads properly and displays all the child nodes, but then deselects the node itself.  How can I get it to stop doing this?






1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 31 Aug 2011, 08:40 AM
Hello Drew,

Can you confirm that the node that is expanded on Load operation is deselected ? The RadTreeViewItem has two selected states: SelectionFocused and SelectionUnfocused. If the node gets unfocussed after the load operation but it is still selected , you can invoke the Focus() method on it in the LoadOnDemand event handler. Is this suitable for you? If this is not the case, it would be easier for us if we can view more from your code. You can also open a new support thread with a project attached. Thank you for your cooperation.

All the best,
Petar Mladenov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
TreeView
Asked by
Drew
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or