WPF网格在单个列中具有多个控件

问题描述:



我有WPF网格,其中有3列
字段名称字段值(单元格控件类型)DataType
-------------------------------------------------- ---------------
PeronName Timo(文本框)字符串
PersonID 1034(文本框)数字
出生日期1985年12月10日(带日历的日期)DateTime
IsMarried是(复选框)布尔值

字段名称和数据类型是只读列,
用户将在字段值"列中输入值
如果字段值可以在单元格中具有文本框或复选框或日历控件.
怎么可能. P
请建议

Hi,

I have WPF grid, in which i have 3 columns
Field Name Field Value (cell control type) DataType
-----------------------------------------------------------------
PeronName Timo (Textbox) string
PersonID 1034 (Textbox) Numeric
Birth Date 10 Dec 1985(Date with Calendar) DateTime
IsMarried Yes(checkbox) boolean

Field Name and data type are read only columns,
User will enter value in "Field Value" column
If field value can have either textbox or checkbox or calendar control in a cell.
How it is possible. P
Please advice

使用DataGridTemplateColumn并在其中包含所有三个控件.
例如

< dg:DataGridTemplateColumn MaxWidth ="250" Header ="Picture">

< dg:DataGridTemplateColumn.CellEditingTemplate>

< DataTemplate>
< StackPanel Orientation =''Horizo​​ntal''>
<!-将这三个控件都放在这里,并根据需要显示/隐藏它们->
</StackPanel>
</DataTemplate>
< dg:DataGridTemplateColumn.CellEditingTemplate>

根据需要选择其中之一.
Use a DataGridTemplateColumn and have all three controls in it.
e.g.

<dg:DataGridTemplateColumn MaxWidth="250" Header="Picture">

<dg:DataGridTemplateColumn.CellEditingTemplate>

<DataTemplate>
<StackPanel Orientation=''Horizontal''>
<!--Have all three controls here and show/hide them as required-->
</StackPanel>
</DataTemplate>
<dg:DataGridTemplateColumn.CellEditingTemplate>

Pick and choose one of them as you require.