开发者

WPF Binding a class

Probably a simple question but one that eludes me nonetheless.

I have a class:

public class Person
{
    public string Name{ get; set; }
    public int Age{ get; set; }
}

An arry of which, is bound to a listview:

    <ListView Name="lvDrawings">
        <ListView.View>
            <GridView>
                <GridViewColumn>
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                         开发者_如何学C   <RadioButton Checked="rbSelected_Checked" GroupName="rbgSelected" Tag="{Binding Path=Person}" />
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
                <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}" />
                <GridViewColumn Header="Age" DisplayMemberBinding="{Binding Path=Age}" />
            </GridView>
        </ListView.View>
    </ListView>

As you can see on the Radio Button I've attempted to bind the class to the tag so that I can utilise the selected row's class. As you can guess, this doesn't work.

How would I be able to do this or is there a much better way.

Thanks in advance, SumGuy


The following will do what you're looking for:

<RadioButton Checked="rbSelected_Checked" GroupName="rbgSelected" Tag="{Binding}" />                        
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜