在WPF DataGrid中调整行标题宽度的大小

编程入门 行业动态 更新时间:2024-10-23 13:28:44
本文介绍了在WPF DataGrid中调整行标题宽度的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个WPF DataGrid(System.Windows.Controls)。

可以调整列标题和行的高度,但我似乎不能找到一种让用户调整行标题宽度的方法。 我希望DataGrid以固定的行标题宽度大小打开,并让用户调整行头的宽度,如果他想要的话,但是没有调整大小的夹持器。

任何想法?

谢谢!

解决方案

在线快速搜索后,我发现了两种实现您的要求的第一部分的方法。您可以使用固定的 RowHeader Width 打开 DataGrid ,如下所示:

< DataGrid ItemsSource ={Binding YourItems}RowHeaderWidth =100>

或像这样:

< DataGrid ItemsSource ={Binding YourItems}> < DataGrid.RowHeaderStyle> < Style TargetType ={x:Type DataGridRowHeader}> < Setter Property =WidthValue =100/> < / Style> < /DataGrid.RowHeaderStyle> < / DataGrid>

RowHeaderStyle 显然让我们设置更多的属性在 DataGridRowHeader ,但不幸的是,我找不到任何方式让用户自己调整大小。

I have a WPF DataGrid (System.Windows.Controls).

It is possible to resize columns headers, and rows height, but i can't seem to find a way to let the user resize the row headers width. I want the DataGrid to open with a fixed row header width size and let the user resize the width of the row header if he wants, but there is no resize gripper for this.

Any idea?

Thanks!

解决方案

After a quick search online, I found two ways to achieve the first part of your requirement. You can open your DataGrid with a fixed RowHeader Width like this:

<DataGrid ItemsSource="{Binding YourItems}" RowHeaderWidth="100">

Or like this:

<DataGrid ItemsSource="{Binding YourItems}"> <DataGrid.RowHeaderStyle> <Style TargetType="{x:Type DataGridRowHeader}"> <Setter Property="Width" Value="100" /> </Style> </DataGrid.RowHeaderStyle> </DataGrid>

The RowHeaderStyle obviously let's us set more properties on the DataGridRowHeader, but unfortunately, I couldn't find any way to let the users resize it themselves.

更多推荐

在WPF DataGrid中调整行标题宽度的大小

本文发布于:2023-11-08 07:47:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568778.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:宽度   大小   标题   WPF   DataGrid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!