今天来和大家聊如何使WPF在窗口外部区域可拖动缩放。
问题来源
对于WPF窗口来说,默认的可拖动缩放区域较小。
在某些应用场景下我们期望能够设置一个较大的可拖动的缩放区域。
自定义WindowChrome
有同学马上想到了,通过WindowChrome
的ResizeBorderThickness
属性进行设置
比如下面的方式
<Window x:Class="WpfApp2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<WindowChrome.WindowChrome>
<WindowChrome ResizeBorderThickness="100">