Button inside RowDetailsTemplate in DataGrid - how to know which row clicked on?
I have this XAML
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<StackPanel>
<Button Content="Reply" Name="btnReply" Click="btnReply_Click" HorizontalAlignment="Left" Margin="5" Padding="10,0" />
<Label Content="{Binding Path=Subject}" FontWeight="Bold" />
<Label Content="{Binding Path=Body}" />
</StackPanel>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
DataGrid bound to List inside btnReply_Click I'd like to get instance of MyObject
Ho开发者_高级运维w do I do this?
var myObject = (sender as FrameworkElement).DataContext as MyObject;
Since the DataContext is inherited.
精彩评论