Hi.
I have an issue to bind two custom classes with comboboxColumn.
My custom classes in viewmodel are below:
public class Logic{ // this is available selections in combobox column
privae int no
private string desc;
public int No { //getter, setter }
public string Desc { //getter, setter}
}
private ObservationCollection<Logic> lstLogic;
public ObservationCollection<Logic> LstLogic { // getter, setter }
public class DetailInfo{ // this includes real data for showing in grids
public int idx {get;set;}
public string name {get; set;}
...
public int logic_no {get;set;}
public string logic_desc {get;set;} // first selected desc in combobox
private ObservationCollection<DetailInfo> lstInfo;
public ObservationCollection<DetailInfo> LstInfo { // getter, setter }
And, in my xaml I binded my custom classes like this.
<ig:XamGrid x:Name="xamGridInfo" ItemSource="{Binding Path=LstInfo, NofityOnTargetChanged=True}">
<ig:XamGrid.Columns>
<ig:TextColumn Key="idx" HeaderText="idx" Width="*" IsReadOnly="True"/>
<ig:TextColumn Key="name" HeaderText="idx" Width="*" IsReadOnly="True"/>
<ig:ComboBoxColumn Key="logic_desc" HeaderText="logic" ItemsSource="{Binding LstLogic}" DisplayMemberPath="Desc" SelectedValuePath="Desc"/>
</ig:XamGrid.Columns>
</ig:XamGrid>
Other text columns are shown well, but only a combobox column shows nothing in it.
Also, I got this bug message:
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=LstLogic; DataItem=null; target element is 'ComboBoxColumn' (HashCode=608860); target property is 'ItemsSource' (type 'IEnumerable')
What should I do..?
I appreciate for your help in advance.
If you explicitly define ResourceDictionary in Window.Resources, you should put your resource inside ResourceDictionary tag as follows.
<Window.Resources> <ResourceDictionary> <local:MyViewModelName x:Key="data"/> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="..."/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Window.Resources>
I have modified the sample from my previous post.
WpfApplication1_resourceDictionary.zip
Hello.
Thanks for your kind answer.
When I tried to use static resource in window.resources, I failed to find my viewmodel.
It is defined like below
<Window ...
xmlns:local="clr-namespace:myProjectName">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..."/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
<local:MyViewModelName x:Key="data"/> <----- failed to find
</Window.Resources>
If I use ResourceDictionary, is it not able to define another resource to use static resource?
Hello,XamGrid columns are not derived from FrameworkElement, so you cannot use DataContext in the ComboBoxColumn's ItemsSource binding. You should use static resource instead.I have created a sample for your reference.
1300.WpfApplication1.zip
Hi,
Thank you for posting in our forums!
I am currently working on this and will update once I have more information.
Best regards,Developer support teamInfragistics