Was to find a solution posted on MSDN (
href="http://social.msdn.microsoft.com/Forums/en/wpf/thread/7fd1df22-03b9-408b-80a4-e0a642a3a857">).
Basically I did the following:
1. Add a MouseDoubleClick in my main DataGrid (this works even though you have DataGridTextColumn or DataGridTemplateColumns as long as your CollectionViewSource is defined and used in the DataGrid).
// Define this in the XAML
<UserControl.Resources>
<ResourceDictionary>
<CollectionViewSource x:Key="TestDataSource"/>
</UserControl.Resources>
</ResourceDictionary>
// In your DataGrid Declaration
<DataGrid Name="DG"
ItemsSource="{Binding Source={StaticResource TestDataSource}}" MouseDoubleClick="CHART_DISPLAY">
Note: TestDataSource was declared and populated in the c# code using the following:
CollectionViewSource dataViewSource = (CollectionViewSource)FindResource("TestDataSource");
dataViewSource.Source = dataList;
// In your C# code:
2. Define the following method in my mainview/window:
private void CHART_DISPLAY(object sender, MouseButtonEventArgs e)
{
if (DG.SelectedItem == null)
{
Debug.WriteLine("Empty");
return;
}
else
{
Debug.WriteLine("Not Empty");
TestData selectedRow = DG.SelectedItem as TestData;
Debug.WriteLine(string.Format("Data = Name={0}, Spread={1}",selectedRow.NAME, selectedRow.SPREAD));
}
}</testdata>
Hope this help you all....wored for me.