0

我有一个 WPF 窗口,没有默认窗口“chrome”。

<Window x:Class="Genesis.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Genesis (Alpha)" Height="812" Width="917" Loaded="Window_Loaded"
    DataContext="{Binding RelativeSource={RelativeSource Self}}" Name="Genesis" Closing="Genesis_Closing"
    WindowStyle="None" BorderThickness="0" Margin="0" ShowInTaskbar="False" AllowsTransparency="True" Background="#F8F8F8"></Window>

由于用于拖动窗口的默认栏不存在,我无法拖动窗口。如何使用新控件重新创建拖动?

4

1 回答 1

2

您需要使用Window.DragMove方法。

从上面的链接:

允许通过鼠标左键向下拖动窗口到窗口客户区的暴露区域。

像这样的东西:

private void Genesis_MouseDown(object sender, MouseButtonEventArgs e)
{
    if (Mouse.LeftButton == MouseButtonState.Pressed )
        this.DragMove();
}
于 2013-01-27T23:54:21.963 回答