This question is locked. New answers and comments are not allowed.
I have a Silverlight app with a RadGridView in it. I am using MVVM-Lite. I have my GridView bound to a Data Collection. Each object in the RGV holds a "IsRead" state attribute. When the "IsRead" is set to "False" I apply a style which is essentially "Bold"; when it is "True" then it applies a style of "Normal Text and Italic". I have a RadContextMenu where the user can right click and select "Is Read". Also, I have implemented an EventTrigger to catch the "KeyUp" event and then bound it to a RelayCommand, passing the Key as a parameter. In my CommandMapping code I assess if the Key was the "Insert Key" then set the "IsRead" accordingly. All these functions work nicely and correctly
.
The challenge I am facing is that after the user presses the "Insert Key" and the Command does its bit, the selected item in the GridView does not appear to still have the focus - i.e. if the user presses say the "Down Key" the selection does not change. Ideally, the user would press "Insert", "Down", "Insert", "Down" x a couple, etc to move around the grid to mark various ones as "IsRead".
How do I keep the focus on the selected item in the grid after the "Insert" is handled?
Segements of the code is as follows:
MainPage.xaml
MainViewModel.cs
Cheers
Rich N
.
The challenge I am facing is that after the user presses the "Insert Key" and the Command does its bit, the selected item in the GridView does not appear to still have the focus - i.e. if the user presses say the "Down Key" the selection does not change. Ideally, the user would press "Insert", "Down", "Insert", "Down" x a couple, etc to move around the grid to mark various ones as "IsRead".
How do I keep the focus on the selected item in the grid after the "Insert" is handled?
Segements of the code is as follows:
MainPage.xaml
<telerik:RadGridView Grid.Row="0" Name="dgCriticalEvents" AutoGenerateColumns="False" ItemsSource="{Binding CriticalEvents, Mode=TwoWay}" SelectedItem="{Binding CurrentCriticalEvent, Mode=TwoWay}" IsReadOnly="True" RowDetailsVisibilityMode="Collapsed" RowDetailsTemplate="{StaticResource CriticalEventDetailsTemplate}" AreRowDetailsFrozen="True" DataLoadMode="Asynchronous" RowIndicatorVisibility="Collapsed" CanUserInsertRows="False" SelectionMode="Extended" Background="Transparent" Foreground="CornflowerBlue" HorizontalGridLinesBrush="CornflowerBlue" VerticalGridLinesBrush="CornflowerBlue" RowStyleSelector="{StaticResource CE_RowStyle}" > <!-- This handles the EventToCommand functionality of GalaSoft MVVLite --> <i:Interaction.Triggers> <i:EventTrigger EventName="KeyUp" > <cmd:EventToCommand Command="{Binding KeyBoardMarkAsRead, Mode=OneWay}" PassEventArgsToCommand="True" /> </i:EventTrigger> </i:Interaction.Triggers> <telerik:RadContextMenu.ContextMenu> <telerik:RadContextMenu Opened="RadContextMenu_Opened" Foreground="#FF004AFF"> <telerik:RadContextMenu.Items> <telerik:RadMenuItem Header="Archive" Command="{Binding RemoveCriticalEvent}"/> <telerik:RadMenuItem Header="No Action Req." Command="{Binding CENoActionRequired}"/> <telerik:RadMenuItem Header="Mark for Follow Up" Command="{Binding CEFollowUp}" /> <telerik:RadMenuItem Header="Client Advised" Command="{Binding CEClientAdvised}"/> <telerik:RadMenuItem Header="Support Contacted" Command="{Binding CESupportContacted}"/> <telerik:RadMenuItem Header="Mark Read/Unread (ins)" Command="{Binding MarkAsRead}" /> <telerik:RadMenuItem Header="Scheduled Maintenance" Command="{Binding CEScheduledMaintenance}" /> </telerik:RadContextMenu.Items> </telerik:RadContextMenu> </telerik:RadContextMenu.ContextMenu>MainViewModel.cs
public RelayCommand<KeyEventArgs> KeyBoardMarkAsRead { get; private set; }...public MainViewModel() { ... KeyBoardMarkAsRead = new RelayCommand<KeyEventArgs>(e => { if (e.Key == Key.Insert) { SetSelectedCriticalEventAsRead(); } }); ... } //---------------------------------------------------------------------------------------- private void SetSelectedCriticalEventAsRead() { foreach (xtn_CriticalEvent ce in SelectedCriticalEventsCollection) { ce.HaveRead = ce.HaveRead ? false : true; SaveSelectedCriticalEvent(ce); } } //---------------------------------------------------------------------------------------- private void SaveSelectedCriticalEvent(xtn_CriticalEvent Source) { if (Source != null) { if (Source.EntityAspect.IsChanged) { Repository.SaveCriticalEvent(Source, () => { // ToDo: Do something??? }); }; }; }....Cheers
Rich N