質問

In the below sample, I try to bind the PartNumber to load into DataGridComboBoxColumn, but I couldn't able to do it. How can I do this?

public class Order
{
    public string OrderName { get; set; }
    public List<Parts> PartsList { get; set; }
}

public class Parts
{
    public string PartName { get; set; }
    public double PartQuantity { get; set; }
    public string PartNumber { get; set; }
}

XAML:

<DataGrid Name="dgrStavke"
          AutoGenerateColumns="False"
          Height="160"
          Width="600"
          HorizontalAlignment="Left"
          Margin="5"
          Grid.Row="7"
          Grid.ColumnSpan="4"
          ItemsSource="{Binding}">
  <DataGrid.Columns>
    <DataGridComboBoxColumn Header="ValueCombo"
                            ItemsSource="{Binding Path=PartsList}"
                            DisplayMemberPath="PartNumber">
  </DataGrid.Columns>
</DataGrid>
役に立ちましたか?

解決

Use ObservableCollection instead of List .If you want to use list then you will have to notify it. But the best way is to use ObservableCollection. I hope this will help.

I just have seen that ItemSource of ComboBox is also not correct it should be like

ItemsSource="{Binding Path=Order.PartsList}"
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top