简体   繁体   English

WPF MVVM中DataGrid单元格中的ComboBox

[英]ComboBox in a DataGrid Cell in WPF MVVM

I am working on a WPF MVVM Project. 我正在研究WPF MVVM项目。

Now i have a DataGrid in which i want this. 现在我有一个DataGrid,我想要这个。

When ever the user comes to the FirstColumn of the DataGrid the Cell should be transformed into ComboBox and when user goes out of that cell the ComboBox should disappear and ComboBox selected value to the CellText. 当用户访问DataGrid的FirstColumn时,Cell应该转换为ComboBox,当用户离开该单元格时,ComboBox应该消失,ComboBox选择值为CellText。

How can i do that. 我怎样才能做到这一点。

Only the selected Cell in the first column should have ComboBox 只有第一列中选​​定的Cell应该有ComboBox

You will find this much easier if you use a DataGrid rather than a GridView . 如果使用DataGrid而不是GridView您会发现这更容易。 The DataGrid has the concept of CellTemplates and CellEditingTemplates built in, which make it very easy to render an edit control whilst the user is editing the cell. DataGrid具有内置CellTemplates和CellEditingTemplates的概念,这使得在用户编辑单元格时可以非常轻松地呈现编辑控件。

Oh yes, and it has a combo-box column type, DataGridComboBoxColumn . 哦,是的,它有一个组合框列类型, DataGridComboBoxColumn

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM