I want bind a list in my viewModel to itemssource of ComboBoxColumn but my code does not work.
but if i use a templatecolumn and in its edittemplate place a combobox, my syntax for itemssource worked
how can i solve my problem?
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ig="http://schemas.infragistics.com/xaml" xmlns:wpfApplication28="clr-namespace:WpfApplication28" x:Class="WpfApplication28.MainWindow" Title="MainWindow" Height="350" Width="525"> <Window.DataContext> <wpfApplication28:ViewModel /> </Window.DataContext> <Grid> <ig:XamGrid AutoGenerateColumns="False" ItemsSource="{Binding Path=Products}"> <ig:XamGrid.EditingSettings> <ig:EditingSettings AllowEditing="Row"/> </ig:XamGrid.EditingSettings> <ig:XamGrid.Columns> <ig:TextColumn HeaderText="Name" Key="Name" Width="200" /> <ig:ComboBoxColumn ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Window}, Path=DataContext.Cities}" Key="City" DisplayMemberPath="Name"/> </ig:XamGrid.Columns> </ig:XamGrid> </Grid></Window>
Hi Krasimir,
I am trying your sample and get an error at
<local:FieldBindingProxyCollection>
preventing the grid to show up in the designer.
The german error message is:
Fehler 1 Der angegebene Wert kann nicht zugewiesen werden. Der folgende Typ wurde erwartet: "FieldBindingProxy". C:\_VS_Projekte\ColumnBindingProxy\ColumnBindingProxy\MainWindow.xaml 19 8 ColumnBindingProxy
meaning
Value cannot be assigned. The following type was expected "FieldBindingProxy".
I am using VS 13 Infra 14.2 under win 8.1. Maybe you can help ?
regards
Uwe
Hello Mohammad,
I am just checking if you require any further assistance on the matter.
Sincerely,
Krasimir, MCPD
Developer Support Supervisor - XAML
Infragistics
www.infragistics.com/support
Thank you for you post. I have been looking into to question that you are having and the ComboBoxColumn is not deriving from the FrameworkElement class and is not part of the Visual Tree of the application, which means that when you are using binding to some of the properties of the Columns of the XamGrid, you should set the Source of the binding.
I have created a sample application for you, that shows how you can create a Binding Proxy class that allows you to bind property of a Column in the Columns collection of the XamGrid to either the XamGrid itself or to its DataContext as follows:
<ig:ComboBoxColumn
Key="City"
DisplayMemberPath="Name">
<local:FieldBindingProxy.FieldBindingProxies>
<local:FieldBindingProxy
BindingSource="DataContext"
PropertyPath="Cities"
FieldPropertyPath="ItemsSource"/>
</local:FieldBindingProxyCollection>
</local:FieldBindingProxy.FieldBindingProxies>
</ig:ComboBoxColumn>
This allows you to bind the ItemsSource of the ComboBoxColumn to the Cities property of the DataContext of the XamGrid.
Please let me know if you need any further assistance on the matter.