This question is locked. New answers and comments are not allowed.
Hello,
I am trying to bring the selected item into view programmatically. This is used during initial population of the tree. The item's ancestors are expanded, and then the item itself is selected by setting the property which is bound to SelectedItem in the RadTreeView. Finally, the RadTreeView's SelectionChanged event is handled as follows:
The expansion and selection works correctly, and the code above is fired after selection, and it identifies the correct item to bring into view - except that it does not bring it into view. The scroll bar remains at the top.
In case of use, here is the XAML that we've used to define the RadTreeView:
I also notice that if I click on an item that is only partially in view, the code above does not bring it fully into view. This isn't a problem for us but maybe it indicates a problem with the code above.
Your help is appreciated - thanks very much.
Ed
I am trying to bring the selected item into view programmatically. This is used during initial population of the tree. The item's ancestors are expanded, and then the item itself is selected by setting the property which is bound to SelectedItem in the RadTreeView. Finally, the RadTreeView's SelectionChanged event is handled as follows:
private
void
RadTreeView_SelectionChanged(
object
sender, SelectionChangedEventArgs e)
{
RadTreeViewItem item = radTreeView.SelectedContainer;
if
(item !=
null
)
{
item.BringIntoView();
}
}
The expansion and selection works correctly, and the code above is fired after selection, and it identifies the correct item to bring into view - except that it does not bring it into view. The scroll bar remains at the top.
In case of use, here is the XAML that we've used to define the RadTreeView:
<
Grid
x:Name
=
"LayoutRoot"
>
<
Grid.RowDefinitions
>
<
RowDefinition
/>
<
RowDefinition
Height
=
"Auto"
/>
</
Grid.RowDefinitions
>
<
ScrollViewer
VerticalScrollBarVisibility
=
"Auto"
HorizontalScrollBarVisibility
=
"Auto"
>
<
telerik:RadTreeView
Name
=
"radTreeView"
ItemTemplate
=
"{StaticResource LocationTemplate}"
ItemsSource
=
"{Binding Path=LocationRoot}"
SelectedItem
=
"{Binding Path=SelectedLocation, Mode=TwoWay}"
SelectionChanged
=
"RadTreeView_SelectionChanged"
/>
</
ScrollViewer
>
<!-- etc. -->
</
Grid
>
I also notice that if I click on an item that is only partially in view, the code above does not bring it fully into view. This isn't a problem for us but maybe it indicates a problem with the code above.
Your help is appreciated - thanks very much.
Ed