I have this problem, and I appreciate if you help me with it.
I have a ViewModel with public ObservableCollection<IProfile> Profiles { get; set; }
Property which fills a DataGrid.
Inside the DataGrid, there is a ComboBox Column:
<DataGridComboBoxColumn
Header="Header"
Width="*"
Visibility="{Binding SelectedType, Converter={Commons:ProfileVisibilityConverter}}"
ItemsSource="{Binding PotentialReinforces}"
SelectedValueBinding="{Binding SectionID, UpdateSourceTrigger=LostFocus, Mode=TwoWay}"
DisplayMemberPath="Name"
SelectedValuePath="ReinforceID"/>
I cannot use a static ItemSource since each row's ComboBox source is different compared to other rows. Therefore, I need dynamic ItemSource
Inside the Profile Class I have defined the PotentialReinforces as below and it provides a suitable result for each object:
public ObservableCollection<Section> PotentialReinforces
{
get
{
var Ids = this != null ? Database.Reinforces.Get.Where(x => x.BlongID == this.SectionID).Select(x => x.SectionID.Value) : new int[0];
if (Ids.Count() > 0)
{
return new ObservableCollection<Section>(Database.ReinforceSections.Get.Where(x => Ids.Contains(x.SectionID)));
}
else return null;
}
}
When I debug the code, each Profile object has the potential collection according to my design but the Combobox doesn't recognize the collection as its ItemSource.
Thank you for your help.