I'm having a DataGrid to list the MobileInfo Collection. The DataGrid is Configured with SelectionUnit="FullRow"
. If I Click the any Row then it selects the entire row with additionally it points the Cell with border where the Mouse was hit. The Border Selection moves while on Keyboard navigation For Example : Left
, Right
, Up
and Down
. Based on the Cell Selection I wish to Pass the Information about the Cell.
Refer the Image it has the Output Screen
In the above Screen Shot the Android is Selected, Based on Keyboard Navigation, the Cell selection gets changed.
My XAML Source Code:
<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding MobileList, UpdateSourceTrigger=PropertyChanged}" SelectionUnit="FullRow" IsReadOnly="True">
<DataGrid.InputBindings>
<KeyBinding Key="C" Modifiers="Ctrl" Command="{Binding Path=DataContext.CopyToClipBoardCommand}" CommandParameter="{Binding }" />
</DataGrid.InputBindings>
<DataGrid.Columns>
<!--Column 1-->
<DataGridTextColumn Binding="{Binding MobileName}" Header="Name" />
<!--Column 2-->
<DataGridTextColumn Binding="{Binding MobileOS}" Header="OS" />
</DataGrid.Columns>
</DataGrid>
Note: Don't Change the SelectionUnit in the DataGrid
Kindly provide your solution, how to pass the Cell Information based on Keyboard Navigation
The C# Source Code associated with the XAML DataGrid
public class GridViewModel
{
public ObservableCollection<MobileInfo> MobileList { get; set; }
public GridViewModel()
{
MobileList = new ObservableCollection<MobileInfo>();
MobileList.Add(new MobileInfo { MobileName = "iPhone", MobileOS = "iOS" });
MobileList.Add(new MobileInfo { MobileName = "Xperia", MobileOS = "Android" });
MobileList.Add(new MobileInfo { MobileName = "Lumina", MobileOS = "Windows" });
}
}
public class MobileInfo
{
public string MobileName { get; set; }
public string MobileOS { get; set; }
}
SelectedItem
and use it in your command processing code instead of trying to pass something viaCommandParameter
. - SinatrICommand
code too? - Il Vic