WPF datagrid和DataGridTemplateColumn中的UserControl [英] WPF A UserControl in a datagrid and a DataGridTemplateColumn

查看:145
本文介绍了WPF datagrid和DataGridTemplateColumn中的UserControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在DataGrid中的用户控件有问题.
我已经将用户控件添加到了DataGridTemplateColumn中,就像这样

Hi,

I have a problem with a user control in a DataGrid.
I have add the usercontrol to the DataGridTemplateColumn, like this

<DataGridTemplateColumn Header="Test" Width="250" x:Name="ColTest" >
  <DataGridTemplateColumn.CellTemplate>
    <DataTemplate x:Name="ColTestDataTemplate">
      <SpecialTextbox Name="foobar" Text="Incorrect width" />
    </DataTemplate>
  </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>



还显示了usercontrol,不幸的是usercontrol的宽度不是列的宽度.

我已经找了几个小时,可惜什么也没找到.
也许有人知道解决方法

谢谢,抱歉我的英语不好.



The usercontrol is also shown, unfortunately the width of the usercontrol is not the width of the column.

I have been looking for a few hours, but unfortunately found nothing.
Maybe someone knows a solution

Thanks and sorry for my bad english

推荐答案

尝试设置 ^ ]到拉伸 [ ^ ] ...(并可能检查是否为UserControl的宽度未设置为xaml)

问候
Espen Harlinn
Try setting HorizontalAlignment[^] to Stretch[^] for the UserControl ... ( and possibly check that the width is not set in xaml for the UserControl )

Regards
Espen Harlinn


感谢,问题不是用户控件,而是控件上的其他元素.
下次我知道了
thanks, the problem was not the usercontrol, but an other element on the control.
for the next time i know it


这篇关于WPF datagrid和DataGridTemplateColumn中的UserControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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