问题描述
- WPF DataGrid列标题重新Template模板 无法使用标题宽度左右拖动
- RT 在重写Template后就无法拖动 请问有什么解决办法?
解决方案
是不是你为DataGrid设置的样式中已经设定为不能拖动列宽度了吧?
解决方案二: <Setter Property=""Template""> <Setter.Value> <ControlTemplate TargetType=""{x:Type GridViewColumnHeader}""> <Grid> <toolkit:DataGridHeaderBorder BorderBrush=""{TemplateBinding BorderBrush}"" x:Name=""dgHeaderBorder"" BorderThickness=""{TemplateBinding BorderThickness}"" Background=""{TemplateBinding Background}"" IsPressed=""{TemplateBinding IsPressed}"" IsHovered=""{TemplateBinding IsMouseOver}"" Padding=""{TemplateBinding Padding}"" > <ContentPresenter HorizontalAlignment=""{TemplateBinding HorizontalContentAlignment}"" SnapsToDevicePixels=""{TemplateBinding SnapsToDevicePixels}"" VerticalAlignment=""{TemplateBinding VerticalContentAlignment}"" Margin=""4040""/> </toolkit:DataGridHeaderBorder> <!--Style=""{DynamicResource ColumnHeaderGripperStyle}""--> <Thumb x:Name=""**PART_HeaderGripper**"" Cursor=""SizeWE"" HorizontalAlignment=""Right"" Background=""{DynamicResource {ComponentResourceKey localCodes:HedmSkins WindowButtonPenColor}}"" Width=""1"" Height=""15"" VerticalAlignment=""Center"" > <Thumb.BitmapEffect> <DropShadowBitmapEffect Color=""#000"" Direction=""-90"" ShadowDepth=""2"" Softness=""0.1"" Opacity=""0.3"" /> </Thumb.BitmapEffect> </Thumb> </Grid> </ControlTemplate> </Setter.Value> </Setter> 解决方案三:
<Style TargetType=""{x:Type GridViewColumnHeader}""> <Setter Property=""Template""> <Setter.Value> <ControlTemplate TargetType=""{x:Type GridViewColumnHeader}""> <Grid> <toolkit:DataGridHeaderBorder BorderBrush=""{TemplateBinding BorderBrush}"" x:Name=""dgHeaderBorder"" BorderThickness=""{TemplateBinding BorderThickness}"" Background=""{TemplateBinding Background}"" IsPressed=""{TemplateBinding IsPressed}"" IsHovered=""{TemplateBinding IsMouseOver}"" Padding=""{TemplateBinding Padding}"" > <ContentPresenter HorizontalAlignment=""{TemplateBinding HorizontalContentAlignment}"" SnapsToDevicePixels=""{TemplateBinding SnapsToDevicePixels}"" VerticalAlignment=""{TemplateBinding VerticalContentAlignment}"" Margin=""4040""/> </toolkit:DataGridHeaderBorder> <!--Style=""{DynamicResource ColumnHeaderGripperStyle}""--> <Thumb x:Name=""**PART_HeaderGripper**"" Cursor=""SizeWE"" HorizontalAlignment=""Right"" Background=""{DynamicResource {ComponentResourceKey localCodes:HedmSkins WindowButtonPenColor}}"" Width=""1"" Height=""15"" VerticalAlignment=""Center"" > <Thumb.BitmapEffect> <DropShadowBitmapEffect Color=""#000"" Direction=""-90"" ShadowDepth=""2"" Softness=""0.1"" Opacity=""0.3"" /> </Thumb.BitmapEffect> </Thumb> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>