Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1770
Dynamically setting ItemsProvider in code behind for xamComboBox
posted

I have a couple of questions.

i want to use the same xamdatagrid for several different data sources. The reason is that  only a few data columns differ. The others are the same. instead of defining two different data grids in xaml and styling the columns there I use the same one and I style the fields in the code behind. So I have

private void OnFieldLayoutInitialized(object sender, FieldLayoutInitializedEventArgs e)
{

if(gridtype1){

var vgDownStyle = new Style(typeof(XamComboEditor));
vgDownStyle.Setters.Add(new Setter(XamComboEditor.ItemsProviderProperty, new DynamicResourceExtension("ValveGroupList1")));

vgDownStyle.Setters.Add(new Setter(XamComboEditor.DisplayMemberPathProperty, new DynamicResourceExtension("ValveGroupName")));

e.FieldLayout.Fields["VG"].Settings.EditorStyle = vgDownStyle;

}else if (gridtype2) {

var vgDownStyle = new Style(typeof(XamComboEditor));
vgDownStyle.Setters.Add(new Setter(XamComboEditor.ItemsProviderProperty, new DynamicResourceExtension("ValveGroupList2")));

vgDownStyle.Setters.Add(new Setter(XamComboEditor.DisplayMemberPathProperty, new DynamicResourceExtension("ValveGroupName")));

e.FieldLayout.Fields["ValveGroupList2"].Settings.EditorStyle = vgDownStyle;

}

is the above code the same as 

<ComboBox Grid.Row="1
ItemsSource="{Binding ValveGroupList1}"
DisplayMemberPath="ValveGroupName"

In terms of the bolded text?

If so it's not binding.

second question is (in the same event method as above)

If I have a loop

foreach (var field in e.FieldLayout.Fields)
{

}

is there a way to loop only through fields that contain a specific character?

Thanks

Parents
No Data
Reply Children