<
UserControl
x:Class
=
"FB_BridgeArchive.View.JobsView"
xmlns:i
=
"clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:cmd
=
"clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:telerikQuickStart
=
"clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls"
mc:Ignorable
=
"d"
d:DesignWidth
=
"300"
d:DesignHeight
=
"400"
DataContext
=
"{Binding Jobs, Source={StaticResource Locator}}"
>
<
UserControl.Resources
>
<
DataTemplate
x:Key
=
"CategoryTemplate"
>
<
TextBlock
Text
=
"{Binding Description}"
/>
</
DataTemplate
>
<
HierarchicalDataTemplate
x:Key
=
"LevelTemplate"
ItemsSource
=
"{Binding Categories}"
ItemTemplate
=
"{StaticResource CategoryTemplate}"
>
<
TextBlock
Text
=
"{Binding Description}"
/>
</
HierarchicalDataTemplate
>
<
HierarchicalDataTemplate
x:Key
=
"TeacherTemplate"
ItemsSource
=
"{Binding Levels}"
ItemTemplate
=
"{StaticResource LevelTemplate}"
>
<
TextBlock
Text
=
"{Binding Name}"
/>
</
HierarchicalDataTemplate
>
</
UserControl.Resources
>
<
StackPanel
Orientation
=
"Vertical"
>
<
telerik:RadTreeView
x:Name
=
"jobTreeView"
Margin
=
"8"
ExpanderStyle
=
"{StaticResource ExpanderStyle}"
IsLoadOnDemandEnabled
=
"True"
IsExpandOnSingleClickEnabled
=
"True"
ItemTemplate
=
"{StaticResource TeacherTemplate}"
ItemsSource
=
"{Binding Path=Ds.Teachers}"
>
<
i:Interaction.Triggers
>
<
i:EventTrigger
EventName
=
"LoadOnDemand"
>
<
cmd:EventToCommand
PassEventArgsToCommand
=
"True"
Command
=
"{Binding LoadOnDemand}"
/>
</
i:EventTrigger
>
</
i:Interaction.Triggers
>
</
telerik:RadTreeView
>
</
StackPanel
>
</
UserControl
>
private void HandleLoadOnDemand(RadRoutedEventArgs e)
{
RadTreeViewItem item = e.OriginalSource as RadTreeViewItem;
if (item.Item.GetType() == typeof(WcfTeacher))
{
Ds.LoadLevels(item.Item as WcfTeacher);
}
else if (item.Item.GetType() == typeof(WcfLevel))
{
Ds.LoadCategories(item.Item as WcfLevel);
}
else
item.IsLoadOnDemandEnabled = false;
}
<telerik:RadGridView x:Name="grid" ItemsSource="{Binding Path(ns:class.property)}"
SelectionMode="Single"
ShowGroupPanel="False" AutoGenerateColumns="False" CanUserDeleteRows="False" CanUserFreezeColumns="False" CanUserInsertRows="False" CanUserReorderColumns="False" CanUserResizeColumns="False"
RowIndicatorVisibility="Collapsed" Controls:StyleManager.Theme="Office_Black" EnableColumnVirtualization="False" EnableRowVirtualization="False" IsFilteringAllowed="False" Controls:RadControl.Theme="Office_Black" ReorderColumnsMode="None"
/>
now when i try to change selected item from code like this:
grid.SelectedItem = Collection[0];
the grid.SelectedItem stays null
even though Collection[0] is not null
i tried to call OnApplyTemplate before assignment but it didn't helped
i tried to do it with two way data binding and it didn't helped too
what can cause this?
and how can i solve it?
thanks
<
Window
x:Class
=
"TreeViewTest.MainWindow"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
Icon
=
"/TreeViewTest;component/ics.ico"
>
<
Grid
>
<
telerik:RadTreeView
HorizontalAlignment
=
"Left"
Name
=
"treeView1"
VerticalAlignment
=
"Top"
IsLineEnabled
=
"True"
FontFamily
=
"Arial"
FontSize
=
"10"
ImagesBaseDir
=
"/Icons/"
IsDragPreviewEnabled
=
"False"
>
<
telerik:RadTreeViewItem
Header
=
"Global"
DefaultImageSrc
=
"Folder_16x16-32.png"
>
<
telerik:RadTreeViewItem
Header
=
"Local 1"
/>
<
telerik:RadTreeViewItem
Header
=
"Local 2"
/>
</
telerik:RadTreeViewItem
>
</
telerik:RadTreeView
>
</
Grid
>
</
Window
>