1

I have a rad grid view that binds its itemssource to a list of 'Employee's. 'Employee' entity has a list of 'Roles' property. How do I bind this 'Roles' to a ListView as below.

As an example: In second column, RadComboBox binds properly. In thrid column, RadRibbonDropDownButton doesn't bind properly. How do i get RolesList bound to ListView inside RadRibbonDropDownButton?

Please help.

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>
lokusking
  • 7,396
  • 13
  • 38
  • 57
Jeevan
  • 181
  • 1
  • 1
  • 8

1 Answers1

0

Adding DataContext={Binding} fixed the binding problem.

Jeevan
  • 181
  • 1
  • 1
  • 8