[英]How to set TextBox to be resized when DataGridTemplateColumn size changes
I tried some stuff but all didn't work.我尝试了一些东西,但都没有奏效。 Maybe I missed something.
也许我错过了什么。 The goal is to have to fill horizontally column with TextEdit and have it autoresized when user change column size by dragging.
目标是必须使用 TextEdit 水平填充列,并在用户通过拖动更改列大小时自动调整大小。
<DataGrid>
<DataGrid.Columns>
<DataGridTemplateColumn Width="200">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<TextBox/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
Add a Header Style
to your DataGrid
.将标题
Style
添加到您的DataGrid
。
<DataGridTemplateColumn Width="200">
<DataGridTemplateColumn.HeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</DataGridTemplateColumn.HeaderStyle>
<DataGridTemplateColumn.HeaderTemplate>
...
</DataGridTemplateColumn.HeaderTemplate>
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.