/ / Codebehind-Bindung von DataGridComboboxColumn in wpf datagrid - c #, wpf, datagrid

Codebehind-Bindung von DataGridComboboxColumn in wpf datagrid - c #, wpf, datagrid

Wie binden Sie diesen Code in den folgenden Code ein:

<Grid >
<Grid.Resources>
<ObjectDataProvider x:Key="ProductDataProvider" ObjectType="{x:Type local:clsPurchaseOrderList}" MethodName="GetProducts" />
</Grid.Resources>

wo mein Datagrid ist als:

<my:DataGrid Name="dgvPurchaseOrder"
ItemsSource="{Binding}"
SelectionUnit="CellOrRowHeader"
TabIndex="3">
<my:DataGrid.Columns>

<my:DataGridComboBoxColumn
Width="100"
Header="Product Code"
SelectedValueBinding="{Binding Path=Product_Id,UpdateSourceTrigger=PropertyChanged}"
SelectedValuePath="Product_Id"
DisplayMemberPath="Product_Code"
ItemsSource="{Binding Source={StaticResource ProductDataProvider}}">
<my:DataGridComboBoxColumn.EditingElementStyle>
<Style TargetType="ComboBox">
<Setter Property="IsEditable" Value="True" />
</Style>
</my:DataGridComboBoxColumn.EditingElementStyle>
</my:DataGridComboBoxColumn>
.
.
.
</my:DataGrid.Columns>
</my:DataGrid>
</Grid>

Ich möchte die DatagridComboboxColumn in Code binden, wie dies zu erreichen ist

Antworten:

0 für die Antwort № 1

versuche etwas wie:

((DataGridComboBoxColumn)PaymentDistributionDataGrid.Columns[1]).ItemsSource = taskGetMortgageInterfaceInformation.Result.TransactionCodes.Where( x => !x.Description.Equals("@"));
((DataGridComboBoxColumn)PaymentDistributionDataGrid.Columns[1]).SelectedValuePath = "Code";
((DataGridComboBoxColumn)PaymentDistributionDataGrid.Columns[1]).SelectedValueBinding = new Binding("MITransactionCode");
((DataGridComboBoxColumn)PaymentDistributionDataGrid.Columns[1]).DisplayMemberPath = "Code";

Wo PaymentDistribution ist mein bearbeitbares Datagrid.