Hi all,
This is probably a very simple WPF binding question (it strikes me that it ought to be!) but I can't find an answer to it so am asking here.
I have a RadDataGrid bound to a collection of business objects (projects, to be specific).
Each project has a lead contact and a customer.
I am displaying customers in a GridViewComboBoxColumn, and contacts in another combo box column.
Currently, I'm data binding Customer combobox to a collection of customers, and the Contacts one to a collection of Contacts, like this:
<telerik:GridViewComboBoxColumn DataMemberBinding="{Binding CustomerId}" UniqueName="Customer" Header="Customer" DisplayMemberPath="CustomerName" SelectedValueMemberPath="CustomerId"></telerik:GridViewComboBoxColumn>
and in the code behind:
((GridViewComboBoxColumn)radarGridView.Columns["Customer"]).ItemsSource = customers.Values;
it's working, in that the lead contact and customer for that project are displayed in the grid - but the dropdown list for Contacts contains *all* contacts and I really want to display only Contacts which belong to the selected customer.
I know I could do this by overriding a databinding event on each row and binding the contacts column to a filtered list of contacts, but I would have to do that for every column which relates to another and I can't believe there isn't an easier way.
i.e. in effect I would like to bind the contacts combobox to something along the lines of (yes, I know this isn't valid C# :):
contacts.Where(c => c.CustomerId == <currently selected customer ID>)
What am I missing?
Kev
This is probably a very simple WPF binding question (it strikes me that it ought to be!) but I can't find an answer to it so am asking here.
I have a RadDataGrid bound to a collection of business objects (projects, to be specific).
Each project has a lead contact and a customer.
I am displaying customers in a GridViewComboBoxColumn, and contacts in another combo box column.
Currently, I'm data binding Customer combobox to a collection of customers, and the Contacts one to a collection of Contacts, like this:
<telerik:GridViewComboBoxColumn DataMemberBinding="{Binding CustomerId}" UniqueName="Customer" Header="Customer" DisplayMemberPath="CustomerName" SelectedValueMemberPath="CustomerId"></telerik:GridViewComboBoxColumn>
and in the code behind:
((GridViewComboBoxColumn)radarGridView.Columns["Customer"]).ItemsSource = customers.Values;
it's working, in that the lead contact and customer for that project are displayed in the grid - but the dropdown list for Contacts contains *all* contacts and I really want to display only Contacts which belong to the selected customer.
I know I could do this by overriding a databinding event on each row and binding the contacts column to a filtered list of contacts, but I would have to do that for every column which relates to another and I can't believe there isn't an easier way.
i.e. in effect I would like to bind the contacts combobox to something along the lines of (yes, I know this isn't valid C# :):
contacts.Where(c => c.CustomerId == <currently selected customer ID>)
What am I missing?
Kev