<telerik:HierarchicalDataTemplate x:Key="DivisionVehicleItem">
<TextBlock Text="{Binding VehicleNumber}"></TextBlock>
</telerik:HierarchicalDataTemplate>
<telerik:HierarchicalDataTemplate x:Key="DivisionVehicle"
ItemsSource="{Binding AVLVehicles}"
ItemTemplate="{StaticResource DivisionVehicleItem}">
<TextBlock Text="{Binding divisionname}"></TextBlock>
</telerik:HierarchicalDataTemplate>
<nav:RadTreeView x:Name="VehicleTreeView"
SelectionMode="Multiple"
ItemsSource="{Binding Path=Divisions, Source={StaticResource TrapezeViewModel}}"
ItemTemplate="{StaticResource DivisionVehicle}"
IsLineEnabled="True"
ItemsOptionListType="CheckList"
IsOptionElementsEnabled="True" />
And the search code looks like this:
private void VehicleQuickSearchTextbox_TextChanged(object sender, TextChangedEventArgs e)
{
string path = string.Empty;
foreach (Division division in VehicleTreeView.ItemsSource)
{
foreach (var vehicle in division.AVLVehicles)
{
if (vehicle.VehicleNumber.StartsWith(VehicleQuickSearchTextbox.Text))
{
path =
string.Format("{0}\\{1}", division.divisionname, vehicle.VehicleNumber);
RadTreeViewItem targetItem = VehicleTreeView.GetItemByPath(path);
if (targetItem != null)
{
targetItem.IsSelected =
true;
}
break;
}
}
if (path.Length > 0)
{
break;
}
}
}
The problem that I am running into is that, no matter what the path is, I always get null for the GetItemByPath call. Can you tell me what I am doing wrong?