Tuesday, September 4, 2012

Can't get the telerik radgridview to highlight the SelectedItem when binding to viewmodel with a selecteditem already set

Can't get the telerik radgridview to highlight the SelectedItem when binding to viewmodel with a selecteditem already set

I have a screen on which I have a telerik RadGridView as the parent/master control. Then I have a child usercontrol showing the details for the selected item.

My grid is set up thus:

<telerik:RadGridView  AutoGenerateColumns="False"  CanUserFreezeColumns="False" IsReadOnly="True"                                      RowIndicatorVisibility="Collapsed" ItemsSource="{Binding LinkedCases}" SelectionUnit="FullRow" SelectionMode="Single"                                      IsBusy="{Binding LinkedCasesLoading}" ShowColumnFooters="True" SelectedItem="{Binding CurrentlySelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" > 

CurrentlySelectedItem is a property on the viewmodel. It is working correctly and populating the details control correctly.

My problem comes when I navigate away and then back to this screen.

The screen is recreated from scratch, but my viewmodel is retrieved from the viewmodel locator (using MVVM Light and SimpleIOC). The Viewmodel is in exactly the condition I require it to be. The Parent grid populates correctly, the child details populate correctly. CurrentlySelectedItem on the ViewModel is populated, but the grid doesn't highlight the selected row.

I've tried with and without Updatesourcetrigger and IsSynchronisedWithCurrentItem but these cause it to select the first row in the grid and highlight that - and thus overwrite my previous value in CurrentlySelectedItem, which isn't what I'm after.

Anyone got any ideas on how to achieve this?

Answers & Comments...




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog