wpf 对于 DataGridRowHeader,CanUserResize=false
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18914586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CanUserResize=false for DataGridRowHeader
提问by Karl_Schuhmann
You can disable resizing the columns of a datagrid.
您可以禁用调整数据网格列的大小。
Is there a way to stop resizing the rowsheader Height
有没有办法停止调整行标题高度
At this moment the user can resize the row Headers. Like this:
此时用户可以调整行标题的大小。像这样:


I want to disable this. So it should always look:
我想禁用它。所以它应该总是看起来:


That's my RowHeaderTemplate
那是我的 RowHeaderTemplate
<DataGrid.RowHeaderTemplate>
<DataTemplate>
<DockPanel FlowDirection="LeftToRight" DataContext="{Binding Item,RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}">
<TextBlock Text="{Binding ZimmerNummer}" MinWidth="48" MaxWidth="48" />
</DockPanel>
</DataTemplate>
</DataGrid.RowHeaderTemplate>
That was my idea:
那是我的想法:
<DataGrid.RowHeaderStyle>
<Style TargetType="DataGridRowHeader">
<Setter Property="MaxHeight"
Value="55"/>
</Style>
</DataGrid.RowHeaderStyle>
But it was not work. That was the result:
但这是行不通的。结果是这样的:


Do someone know a Solution for that?
有人知道解决方案吗?
回答by dkozl
If you want to disable resizing on your DataGridthen you can do something like this:
如果要禁用调整大小,DataGrid则可以执行以下操作:
<DataGrid CanUserResizeColumns="False" CanUserResizeRows="False" .../>

