I have a class in Model.cs and list of the objects of this class is created in viewmodel.cs.
I using the list of these objects as anItemsource
to the Data Gridview. Each of the object in the list has Name
as a property and I want list of these names in the each of the comboxes in the DataGridComboBoxColumn
. I tried quite a few things and I'm unable to get the desired result. I'm using Prism for this application
I have the following code in ViewModel.cs
private IList<BeamData> _allBeams
public IList<BeamData> AllBeams
{
get { return _allBeams; }
set { _allBeams = value; }
}
public LoadInfoViewModel()
{
_allBeams = new List<BeamData>()
{
new BeamData(){Name ="B1"},
new BeamData(){Name ="B2"},
new BeamData(){Name ="B3"}
};
}
}
The beam data class looks like this :
public BeamData()
{
}
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
My XAML files has this code
<DataGrid x:Name="Table" ItemsSource="{Binding AllBeams, UpdateSourceTrigger=Explicit}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridComboBoxColumn ItemsSource="{Binding AllBeams}"
DisplayMemberPath="Name">
</DataGridComboBoxColumn>
</DataGrid.Columns>
</DataGrid>
Fyi, This does not answer my question.
Desired output :
If you look at the code above, B1, B2, B3
are Name (property) of the object BeamData, each combo boxes in the column should have all the names Viz, B1 , B2, B3