My problem is this.
My TreeListView has a two-way binding on the SelectedItem property. If I add a new item to the underlying hierarchical data, it appears in the grid and is selected how I would expect, but only if the branch of the tree I am adding to is expanded. If I add a new item to a currently collapsed group, the proeprty I am binding to (SelectedLocation in my case) updates as expected but the parent branch remains collapsed and the tree's rendering does not change. This makes it look like the previously selected item is still selected.
Is there a solution to this that is pure MVVM (ie. no code behind the window)?
I have tried setting the AutoExpandGroups to true to see if this helped. However, there appears to be a bug in this. In my data I have two root objects, each with several children, grandchildren, etc. When I have AutoExpandGroups set to true, only the first root and the first child are displayed. Everything else only appears if you collapse and re-expand nodes. I'm assuming I'm stuck with this because of not being able to upgrade to the later version of the controls due to the breaking change in the GridView.
My current TreeListView's XAML is:
<Grid Visibility="{Binding .,Converter={StaticResource PermissionCodeConverter},ConverterParameter='SHOW LOCATIONS'}">
<telerik:RadTreeListView Name="LocationTree"
ItemsSource="{Binding Locations}"
SelectedItem="{Binding SelectedLocation,Mode=TwoWay}"
IsReadOnly="True"
AutoGenerateColumns="False"
CanUserFreezeColumns="False"
CanUserReorderColumns="False"
RowIndicatorVisibility="Collapsed"
<telerik:RadTreeListView.SortDescriptors>
<telerik:SortDescriptor Member="Name" SortDirection="Ascending"/>
</telerik:RadTreeListView.SortDescriptors>
<telerik:RadTreeListView.ChildTableDefinitions>
<telerik:TreeListViewTableDefinition ItemsSource="{Binding ChildLocations}" />
</telerik:RadTreeListView.ChildTableDefinitions>
<telerik:RadTreeListView.Columns>
<telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" Width="200">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding IconResourcePath}" Width="16" Height="16" HorizontalAlignment="Left" Margin="0 0 8 0"/>
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding LocationType.Description}" Header="Type" Width="175" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding CheckDigits}" Header="Check Digits" Width="115" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding DisplayablePalletLimit}" Header="Maximum Pallets" Width="125" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Status}" Header="Status" Width="100" />
</telerik:RadTreeListView.Columns>
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu x:Name="GridContextMenu">
<telerik:RadContextMenu.Items>
<telerik:RadMenuItem Header="Create Child" Command="{Binding CreateChildLocationCommand}">
<telerik:RadMenuItem.IconTemplate>
<DataTemplate>
<Image Source="..\Images\16x16\Create.png"/>
</DataTemplate>
</telerik:RadMenuItem.IconTemplate>
</telerik:RadMenuItem>
<telerik:RadMenuItem Header="Edit" Command="{Binding EditLocationCommand}" Style="{StaticResource DefaultContextMenuItem}">
<telerik:RadMenuItem.IconTemplate>
<DataTemplate>
<Image Source="..\Images\16x16\Edit.png"/>
</DataTemplate>
</telerik:RadMenuItem.IconTemplate>
</telerik:RadMenuItem>
<telerik:RadMenuItem Header="Delete" Command="{Binding DeleteLocationCommand}">
<telerik:RadMenuItem.IconTemplate>
<DataTemplate>
<Image Source="..\Images\16x16\Delete.png"/>
</DataTemplate>
</telerik:RadMenuItem.IconTemplate>
</telerik:RadMenuItem>
<telerik:RadMenuItem IsSeparator="True" />
<telerik:RadMenuItem Header="Enable" Command="{Binding EnableLocationCommand}">
<telerik:RadMenuItem.IconTemplate>
<DataTemplate>
<Image Source="..\Images\16x16\Enable.png"/>
</DataTemplate>
</telerik:RadMenuItem.IconTemplate>
</telerik:RadMenuItem>
<telerik:RadMenuItem Header="Disable" Command="{Binding DisableLocationCommand}">
<telerik:RadMenuItem.IconTemplate>
<DataTemplate>
<Image Source="..\Images\16x16\Disable.png"/>
</DataTemplate>
</telerik:RadMenuItem.IconTemplate>
</telerik:RadMenuItem>
<telerik:RadMenuItem IsSeparator="True" />
<telerik:RadMenuItem Header="Refresh" Command="{Binding RefreshCommand}">
<telerik:RadMenuItem.IconTemplate>
<DataTemplate>
<Image Source="..\Images\16x16\Refresh.png"/>
</DataTemplate>
</telerik:RadMenuItem.IconTemplate>
</telerik:RadMenuItem>
</telerik:RadContextMenu.Items>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</telerik:RadTreeListView>