Hi,
I am strugling to find a way where I can bind a list of string to a dropdown in edit mode of a column. I am using following style to create a dropdown in editmode. This works fine and creates a dropdown in editmode. What I want is that it should show a different list in the dropdown for different columns. I am crating the columns at runtime and do not kow how many columns will be there. So the following style show me the same list of values in dropdown in every dropdown. The requirement is that it should show the different values for every column.
Please help.
Style I am using currently, to show same list of values to every dropdown.
<Style TargetType="{x:Type igED:XamComboEditor}" x:Key="comboStyle2">
<Setter Property="ItemsSource" Value="{Binding Path=G1List, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}},Mode=TwoWay}" />
<Setter Property="Width" Value="90"/>
<Style.Triggers> <Trigger Property="IsEnabled" Value="False"> <Setter Property="BorderThickness" Value="0"/> <Setter Property="Background" Value="Transparent" /> </Trigger> </Style.Triggers></Style>
Regards,
Shishir
Thanks a lot. It helped me.
Hello Shihir,
You can do the same thing in code behind by handling the XamDataGrid’s FieldLayoutInitialized event and using this code in its handler:
private void xamDataGrid1_FieldLayoutInitialized(object sender, Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs e)
{
Style myEditorStyle1 = new Style(typeof(XamComboEditor));
myEditorStyle1.Setters.Add(new Setter(XamComboEditor.ItemsSourceProperty, list1));
e.FieldLayout.Fields["name"].Settings = new FieldSettings() { EditorStyle = myEditorStyle1 };
Style myEditorStyle2 = new Style(typeof(XamComboEditor));
myEditorStyle2.Setters.Add(new Setter(XamComboEditor.ItemsSourceProperty, list2));
e.FieldLayout.Fields["department"].Settings = new FieldSettings() { EditorStyle = myEditorStyle2 };
}
Please let me know if you require any further assistance on this matter.
Thanks for the reply, It helped me understand the concept.
Only difference between my scenario and your sample is that, in my scenario the columns are added at runtime, and hence I do not know how many columns could be there. Similarly List1 and List2 in my scenario is dynamically created.
It would be great, If you can tell me how to achieve the same thing at runtime through codebehind.
Thanks a lot,
Hello Shishir,
I have read through your last response, however this doesn’t help me understand what is your scenario. Nevertheless I have created a sample project for you that shows two columns with different XamComboEditors (WpfApplication1.zip).
Hope this helps.
I have a list of different values that can be bound to these dropdowns.
But I am not able to bind them properly. In a single row, I have 2 different columns (same header) which needs dropdown to be shown with different values in edit mode.
Any help is highly appreciated. Unfortunately, I cannot provide a test sample for this.
Thanks,