1
我是新手WPF程序員。我的問題如下。WPF窗口沒有最小化/最大化
我有一個WPF應用程序,並在主屏幕上,當我點擊最大化按鈕,它不會最大化屏幕,而是重新定位到左上角的列。如果我通過點擊和拖動來增加/減少屏幕大小,最大化按鈕就可以正常工作。窗口屬性設置如下:
<Window x:Class="MyApp.Home"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
x:Uid="Window_Main"
x:Name="HomeWindow"
WindowStyle="None"
AllowsTransparency="True"
WindowStartupLocation="CenterScreen"
Margin="0"
BorderBrush="Transparent"
BorderThickness="0"
Title="Home"
MinWidth="1000" MinHeight="800"
ResizeMode="CanResizeWithGrip"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
SizeToContent="WidthAndHeight"
Visibility="Visible"
d:DesignHeight="1080" d:DesignWidth="1200">
的按鈕的XAML是:
<Button x:Uid="btnRestore" x:Name="btnRestore" Height="20" Width="20" Style="{DynamicResource Control_WindowControlBoxStyle}" Margin="5,0,0,0" ToolTip="Toggle Restore" Click="btnRestore_Click" />
而對於btnRestore_Click的代碼很簡單:
private void btnRestore_Click(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Maximized;
}
我相信一定有我犯了一些愚蠢的錯誤,但無法弄清楚那是什麼。似乎很簡單,但讓我陷入困境。任何幫助,將不勝感激。
太謝謝你了。我知道這並不複雜,但由於缺乏經驗而缺席。它解決了我的問題。 – 2012-02-09 07:56:45