I'm fairly new to WPF and still trying to understand the bindings. I've been successful a few times, however I am struggling here.
I am Binding a Datagrid to a List<> type object. 2 of my datagrid columns bind successfully, however I'm struggling to bind my DataGridComboBoxColumn.
My DataGrid is as follows:
<DataGrid Name="CustomerList" AutoGenerateColumns="False" AlternatingRowBackground="AliceBlue" ItemsSource="{Binding Source=customers}">
<DataGrid.Columns>
<DataGridTextColumn Header="BP Code" Binding="{Binding Path=CardCode}"/>
<DataGridTextColumn Header="BP Name" Binding="{Binding Path= CardName}"/>
<DataGridComboBoxColumn x:Name="EDIcombo" Header="EDI Format" ItemsSource="{StaticResource sEdiFormat}" DisplayMemberPath="Key" SelectedValuePath="EdiFormat"/>
</DataGrid.Columns>
</DataGrid>
This pulls static values for the selectable options on the drop down- this part works fine and I get my list of values to choose from, however I don't have the default value that should be pulled from the 'Selected Value Path'
My List object is as follows:
public class EDICustomers
{
public string CardCode { get; set; }
public string CardName { get; set; }
public string EdiFormat { get; set; }
public EDICustomers(string cardcode, string cardname, string ediFormat)
{
this.CardCode = cardcode;
this.CardName = cardname;
this.EdiFormat = ediFormat;
}
}
My method that runs sets the ItemSource of the Datagrid to be the List<> object in question. I'm confident that the issue is with the binding of the SelectedValue.