Combobox没有在datagrid xaml WPF上集合集合 [英] Combobox not bining collection inside collection on datagrid xaml WPF

查看:104
本文介绍了Combobox没有在datagrid xaml WPF上集合集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ComboBox not bining collection inside collection on DataGrid xaml wpf





我尝试过:





What I have tried:

<pre>
xaml code inside DataGrid
<DataGridTemplateColumn Header="Unit" Width="65"> 
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <my:PLGDComboBox Height="23"
                             ItemsSource="{Binding Path=SaveCls.PurDtlMastCol[RowIndx].ItemUnitCol,RelativeSource={RelativeSource AncestorType={x:Type invname:MasterForm},AncestorLevel=1,Mode=FindAncestor},UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                             SelectedValue="{Binding  Path=PurUnit.UnitId,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" 
                             DisplayMemberPath="UnitName"
                             SelectedValuePath="UnitId"/>
    </DataTemplate >
</DataGridTemplateColumn.CellTemplate>









查看型号代码:







View Model Code:

if (dtUnit.Rows.Count > 0) 
   { 
     this.SaveCls.PurDtlMastCol[rowIndex].ItemUnitCol = new PL21000DCol(); 
     foreach (DataRow dr in dtUnit.Rows)
     {
        this.SaveCls.PurDtlMastCol[rowIndex].ItemUnitCol.Add(new PL21000D() { 
        UnitId = PLWM.Utils.CnvToInt64(dr["unit_id"]),
        UnitName = PLWM.Utils.CnvToStr(dr["unit_name"]) 
        });
     }
   }

推荐答案

我做了一个快速谷歌搜索 [ ^ ]并发现:



将WPF DataGridComboBoxColumn绑定到MVVM - 堆栈溢出 [ ^ ]
I did a quick Google search[^] and found this:

Binding a WPF DataGridComboBoxColumn with MVVM - Stack Overflow[^]


这篇关于Combobox没有在datagrid xaml WPF上集合集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆