开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜