I have a datagrid with a datagridComboBoxColumn. The items source of the datagrid is a custom class called Products which has a property called Installer (also a custom class called Contact).
I want to bind the datagridComboBoxColumn itemsSource to all the Contacts, and the selected value of the comboBox to the Installer. This is not working, could anyone please give me a hand? Thanks in advance
It would be much appreciated. I have seen other similar posts (like this one or this one ) but it's not exactly the same situation.
My xaml code:
<DataGrid x:Name="productsList" AutoGenerateColumns="False" IsReadOnly="True" CanUserResizeRows="False"
CanUserResizeColumns="True" ColumnWidth="*" GridLinesVisibility="None">
<DataGrid.Columns>
<DataGridTextColumn Header="Ref"
Binding="{Binding Ref}"
/>
<DataGridTextColumn Header="Product"
Binding="{Binding Product}"
/>
<DataGridComboBoxColumn Header="Installer" SelectedItemBinding="{Binding Installer, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding Contacts}"/>
</DataGrid.Columns>
</DataGrid>
My code-behind:
public partial class CatalogPage : Page
{
ObservableCollection<CatalogProduct> mProductList = new ObservableCollection<CatalogProduct>();
public ObservableCollection<Contact> Contacts
{
get
{
return Parent.mContactsPage.GetContacts();
}
}
private LocalConfigurationPage Parent { get; set; }
public CatalogPage(LocalConfigurationPage localConfigurationPage)
{
InitializeComponent();
Parent = localConfigurationPage;
productsList.ItemsSource = mProductList;
}
}
This is the CatalogProduct class:
public class CatalogProduct
{
public string Ref { get; set; }
public string Product { get; set; }
public Contact Installer { get; set; }
}