在wpf中隐藏默认的调整大小夹点
我有一个WPF的无边界透明窗口,底部有一些花哨的装饰。有一个自定义的页脚与一些非传统的曲线和什么不显示该公司的标志。与传统窗口一样,此窗口需要通过右下角的夹点调整大小 无论如何,我已经将自己的ResizeGrip放在了页脚上的一个位置,但是默认的夹点仍然显示出来,并且由于不可见的窗口,它在空间中浮动在wpf中隐藏默认的调整大小夹点,wpf,resizegrip,Wpf,Resizegrip,我有一个WPF的无边界透明窗口,底部有一些花哨的装饰。有一个自定义的页脚与一些非传统的曲线和什么不显示该公司的标志。与传统窗口一样,此窗口需要通过右下角的夹点调整大小 无论如何,我已经将自己的ResizeGrip放在了页脚上的一个位置,但是默认的夹点仍然显示出来,并且由于不可见的窗口,它在空间中浮动 如何隐藏默认的调整大小夹点?调整大小夹点的外观通过窗口上的dependency属性进行控制 如果设置为CanResizeWithGrip: 窗口将如下所示: 如果设置为CanResize(默认
如何隐藏默认的调整大小夹点?调整大小夹点的外观通过窗口上的dependency属性进行控制 如果设置为CanResizeWithGrip:
窗口将如下所示:
如果设置为CanResize(默认值):
窗口的外观如下所示:
为了隐藏默认夹点,我重写了默认的ResizeGrip样式,以便隐藏其可见性。借助Expression Blend 2,操作简单
<Style TargetType="{x:Type ResizeGrip}">
<Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
<Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ResizeGrip}">
<Grid SnapsToDevicePixels="True" Background="{TemplateBinding Background}">
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Visibility" Value="Hidden"/>
</Style>
然后,我在自定义窗装饰上设置了自己的大小调整夹点,其样式与默认夹点样式相同
<SolidColorBrush x:Key="ResizeGripperForeground" Color="#B8B4A2"/>
<Style x:Key="VisibleResizeGrip" TargetType="{x:Type ResizeGrip}">
<Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
<Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ResizeGrip}">
<Grid SnapsToDevicePixels="True" Background="{TemplateBinding Background}">
<Path Fill="White" HorizontalAlignment="Right" Margin="0,0,2,2" VerticalAlignment="Bottom" Data="M 8,0 L 10,0 L 10,2 L 8,2 Z M 4,4 L 6,4 L 6,6 L 4,6 Z M 8,4 L 10,4 L 10,6 L 8,6 Z M 0,8 L 2,8 L 2,10 L 0,10 Z M 4,8 L 6,8 L 6,10 L 4,10 Z M 8,8 L 10,8 L 10,10 L 8,10 Z"/>
<Path Fill="{StaticResource ResizeGripperForeground}" HorizontalAlignment="Right" Margin="0,0,3,3" VerticalAlignment="Bottom" Data="M 8,0 L 10,0 L 10,2 L 8,2 Z M 4,4 L 6,4 L 6,6 L 4,6 Z M 8,4 L 10,4 L 10,6 L 8,6 Z M 0,8 L 2,8 L 2,10 L 0,10 Z M 4,8 L 6,8 L 6,10 L 4,10 Z M 8,8 L 10,8 L 10,10 L 8,10 Z"/>
<Path Data="M8,0L10,0 10,2 8,2z M4,4L6,4 6,6 4,6z M8,4L10,4 10,6 8,6z M0,8L2,8 2,10 0,10z M4,8L6,8 6,10 4,10z M8,8L10,8 10,10 8,10z" Fill="White" HorizontalAlignment="Right" Margin="0,0,2,2" VerticalAlignment="Bottom" />
<Path Data="M8,0L10,0 10,2 8,2z M4,4L6,4 6,6 4,6z M8,4L10,4 10,6 8,6z M0,8L2,8 2,10 0,10z M4,8L6,8 6,10 4,10z M8,8L10,8 10,10 8,10z" Fill="{StaticResource ResizeGripperForeground}" HorizontalAlignment="Right" Margin="0,0,3,3" VerticalAlignment="Bottom" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
@SebastianNegraszus我添加了一些新的。