开发者

C# WPF Binding Get Reference To Source Row From Selected Item

Binding a ListView:

ItemsSource="{Binding Path=DF.DocFieldEnum1rows, Mode=OneWay}".  
开发者_运维百科

DF.DocFieldEnum1rows is List<DocFieldEnum1row>.

Item template binding:

<Button  Content="{Binding Path=FieldEnum1Row.StrValue, Mode=OneWay}" 
    Click="Button_Click" />.  

In the Button_Click I get access to the Path=FieldEnum1Row.StrValue value, but how can I get access to the source DocFieldEnum1row?


The DataContext of your Button should be the instance of the row.

private void buttonClickHandler(object sender, EventArgs e)
{
    Button b = (Button)sender;

    var row = (YourRowType)b.DataContext;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜