我有自定義窗口WindowState=WindowState.Maximized
與邊框和拇指內邊框,似乎當我無法拖動和自定義窗口移動到不同的屏幕時WindowState=WindowState.Maximized
。WPF拇指拖動和WindowState.Maximized移動
的XAML:
<Window x:Class="WpfApplication3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
Height="350"
Width="525"
WindowStyle="None">
<Border Name="headerBorder"
Width="Auto"
Height="50"
VerticalAlignment="Top"
CornerRadius="5,5,0,0"
DockPanel.Dock="Top"
Background="Red"
BorderThickness="1,1,1,1"
BorderBrush="Yellow">
<Grid x:Name="PART_Title">
<Thumb x:Name="headerThumb"
Opacity="0"
Background="{x:Null}"
Foreground="{x:Null}"
DragDelta="headerThumb_DragDelta"/>
</Grid>
</Border>
</Window>
C#:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
WindowState = System.Windows.WindowState.Maximized;
}
private void headerThumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
{
Left = Left + e.HorizontalChange;
Top = Top + e.VerticalChange;
}
}
我也覆蓋MouseLeftButtonDown
方法和使用DragMove()
內,但沒有成功。我也嘗試訂閱拇指的MouseLeftButtonDown
並在那裏寫入DragMove()
但沒有成功。
你嘗試使用[WindowChrome](https://msdn.microsoft.com/en-us/ library/system.windows.shell.windowchrome%28v = vs.110%29.aspx)在.NET 4.5中?它允許你有一個沒有任何樣式和邊框的窗口,並且能夠像經典窗口一樣操作它(甚至在WindowState Maximized中)。 – Max