I have this grid and on doubleclick I'd like to capture the
CorrectionID, values to pass on to a new window. Can anyone guide
me>
private void dgCorrectionHistory_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("You have just selected " + DataGridTextColumn.HeaderStringFormatProperty.ToString() + row);
}
<dg:DataGrid Name="dgCorrectionHistory" AutoGenerateColumns="False"
SelectionMode="Single" GridLinesVisibility="None" HeadersVisibility="Column"
RowDetailsVisibilityMode="VisibleWhenSelected"
SelectedIndex="0" Grid.IsSharedSizeScope="False"
HorizontalAlignment="Stretch" IsTabStop="True" TabIndex="1"
CanUserAddRows="False" CanUserResizeColumns="False" CanUserResizeRows="False" IsTextSearchEnabled="True"
Loaded="dgCorrectionHistory_Loaded"
EnableRowVirtualization="False" Focusable="False"
PreviewKeyDown="dgCorrectionHistory_PreviewKeyDown"
PreparingCellForEdit="dgCorrectionHistory_PreparingCellForEdit"
CellEditEnding="dgCorrectionHistory_CellEditEnding"
BeginningEdit="dgCorrectionHistory_BeginningEdit"
MouseDown="dgCorrectionHistory_MouseDown"
LostFocus="dgCorrectionHistory_LostFocus"
MouseLeave="dgCorrectionHistory_MouseLeave"
MouseDoubleClick="dgCorrectionHistory_MouseDoubleClick" PreviewMouseDown="dgCorrectionHistory_PreviewMouseDown">
<dg:DataGrid.GroupStyle>
</dg:DataGrid.GroupStyle>
<dg:DataGrid.RowDetailsTemplate >
<DataTemplate>
<Border HorizontalAlignment="Stretch" CornerRadius="5"
Background="Black" Margin="5" Padding="5">
<StackPanel Orientation="Horizontal">
<TextBlock Foreground="White" Text="{Binding Path=Notes}"
MaxWidth="700" TextWrapping="WrapWithOverflow" ></TextBlock>
</StackPanel>
</Border>
</DataTemplate>
</dg:DataGrid.RowDetailsTemplate>
<dg:DataGrid.Columns >
<dg:DataGridTextColumn Header="CorrectionID" IsReadOnly="True"
Binding="{Binding Path=CorrectionID}" Visibility="Visible" />
<dg:DataGridTemplateColumn
Header="Inspection Type" Visibility="Visible" MaxWidth="152"
MinWidth="152">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=InspectionType}" TextWrapping="WrapWithOverflow"/>
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
<dg:DataGridTextColumn Header="Violation Type" IsReadOnly="True"
Binding="{Binding Path=ViolationType}" MaxWidth="175" MinWidth="175"
/>
<dg:DataGridTextColumn
Header="Inspector" IsReadOnly="True" Binding="{Binding Path=IssuedBy}"
MaxWidth="100" MinWidth="100" />
<dg:DataGridTextColumn Header="Code" IsReadOnly="True"
Binding="{Binding Path=ComplianceCode}" MaxWidth="150" MinWidth="150"
/>
<dg:DataGridTextColumn
Header="Record Date" IsReadOnly="True" Binding="{Binding
Path=RecordDate}" MaxWidth="125" MinWidth="125" />
<dg:DataGridTextColumn Header="Status" IsReadOnly="True"
Binding="{Binding Path=Status}" MaxWidth="75" MinWidth="75" />
<dg:DataGridTextColumn Header="Close Date" IsReadOnly="True"
Binding="{Binding Path=CloseDate}" MaxWidth="100" MinWidth="125"/>
<dg:DataGridTemplateColumn Header="(A)" Visibility="Visible" MinWidth="50" MaxWidth="50" >
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="Close" Foreground="Black" FontSize="12"
VerticalAlignment="Center" MaxWidth="50" Click="Button_Click"
Tag="{Binding Path=CloseDate}" Uid="{Binding Path=CorrectionID}" />
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
</dg:DataGrid.Columns>
</dg:DataGrid>