WPF工具包datagrid单元格文本换行 [英] WPF toolkit datagrid cell text wrapping

查看:1056
本文介绍了WPF工具包datagrid单元格文本换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的WPF数据网格的列是固定的宽度,这意味着行中的长文本被切断。如何使文本包装?

解决方案

如果您使用DataGridTextColumn,则需要为DataGridTextColumn定义样式。 ElementStyle

 < dg:DataGridTextColumn Header =SomeLongTextBinding ={Binding MyText}> 
< dg:DataGridTextColumn.ElementStyle>
< Style TargetType =TextBlock>
< Setter Property =TextWrappingValue =Wrap/>
< / Style>
< / dg:DataGridTextColumn.ElementStyle>
< / dg:DataGridTextColumn>

完整的解释可以在以下 http://msdn.microsoft.com/en-us/library/system.windows .controls.datagridtextcolumn(v = vs95).aspx


My WPF datagrid's columns are fixed width, which means long text in the rows are cut off. How can I have the text wrap?

解决方案

If you are using a DataGridTextColumn, you need to define the Style for the DataGridTextColumn.ElementStyle

<dg:DataGridTextColumn Header="SomeLongText" Binding="{Binding MyText}">
  <dg:DataGridTextColumn.ElementStyle>
    <Style TargetType="TextBlock">
      <Setter Property="TextWrapping" Value="Wrap"/>
    </Style>
  </dg:DataGridTextColumn.ElementStyle>
</dg:DataGridTextColumn>

Full explination can be found at the following http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridtextcolumn(v=vs.95).aspx

这篇关于WPF工具包datagrid单元格文本换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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