我有一个rad grid视图,它将itemssource绑定到' Employee的列表。
'员工'实体有一个'角色列表'属性。我该如何约束这个角色'到ListView
,如下所示。
作为示例:在第二列中,RadComboBox
正确绑定。在第三列中,RadRibbonDropDownButton
没有正确绑定。
如何在ListView
内绑定RadRibbonDropDownButton
的RolesList?
请帮忙。
class Employee
{
public string Name {get; set;}
public List<Role> RolesList {get; set;}
}
class Role
{
public int RoleId {get; set;}
public string RoleName {get; set;}
public string RoleCategory {get; set;}
}
<tk:RadGridView ItemsSource="{Binding Path=EmployeeList,Mode=TwoWay}" AutoGenerateColumns="False">
<tk:RadGridView.Columns>
<tk:GridViewDataColumn Header="Employee Name" DataMemberBinding="{Binding Name}" IsReadOnly="True"/>
<tk:GridViewDataColumn Header="Roles" Width="410">
<tk:GridViewDataColumn.CellTemplate>
<DataTemplate>
<!--this binds properly-->
<tk:RadComboBox ItemsSource="{Binding RolesList}" DisplayMemberPath="RoleName" SelectedValuePath="RoleId" />
</DataTemplate>
</tk:GridViewDataColumn.CellTemplate>
</tk:GridViewDataColumn>
<tk:GridViewDataColumn Header="Roles" Width="410">
<tk:GridViewDataColumn.CellTemplate>
<DataTemplate>
<tk:RadRibbonDropDownButton>
<tk:RadRibbonDropDownButton.DropDownContent>
<ListView ItemsSource="{Binding RolesList}">
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridViewColumn DisplayMemberBinding="{Binding RoleName}" Header="Role Name" Width="75" ></GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding RoleCategory}" Header="Role Category" Width="175" ></GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</tk:RadRibbonDropDownButton.DropDownContent>
</tk:RadRibbonDropDownButton>
</DataTemplate>
</tk:GridViewDataColumn.CellTemplate>
</tk:GridViewDataColumn>
</tk:RadGridView.Columns>
</tk:RadGridView>
答案 0 :(得分:0)
添加DataContext = {Binding}修复了绑定问题。