WPF网格在单个列中具有多个控件 [英] Wpf grid with multi controls in a single column

查看:115
本文介绍了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.


这篇关于WPF网格在单个列中具有多个控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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