I have a very generic WPF window that starts maximized. When this window is minimized to task bar, and then restored the window no longer fills the screen. It shows a small portion of the desktop on the right hand side. Windows still considers it as maximized and when set to normal and then maximized again it looks like it should until being minimized again.
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
this.MaxWidth = SystemParameters.MaximizedPrimaryScreenWidth;
}
private void ExitBtn_Click(object sender, MouseButtonEventArgs e)
{
this.Close();
}
private void MaxBtn_Click(object sender, MouseButtonEventArgs e)
{
this.WindowState = WindowState.Maximized;
//Application.Current.MainWindow.WindowState = WindowState.Maximized;
resizeBtn.Visibility = Visibility.Visible;
maximizeBtn.Visibility = Visibility.Hidden;
}
private void ResBtn_Click(object sender, MouseButtonEventArgs e)
{
this.WindowState = WindowState.Normal;
resizeBtn.Visibility = Visibility.Hidden;
maximizeBtn.Visibility = Visibility.Visible;
}
private void MinBtn_Click(object sender, MouseButtonEventArgs e)
{
this.WindowState = WindowState.Minimized;
}
private void TitleBar_DblClick(object sender, MouseButtonEventArgs e)
{
if (this.WindowState == WindowState.Normal){ this.WindowState = WindowState.Maximized; return; }
if (this.WindowState == WindowState.Maximized) { this.WindowState = WindowState.Normal; return; }
}
}
Your thoughts? UPDATE:
Seems to related to the can resize property. If I set it to ca minimize it is fine. resize with grip or can resize cause the window to change sizes after being minimized to task bar.
<Window x:Class="QuoteClient.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"
xmlns:local="clr-namespace:QuoteClient"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525" WindowStyle="None" Background="Black" BorderBrush="Black">
<Grid>
<local:TitleBar VerticalAlignment="Top" MouseDoubleClick="TitleBar_DblClick"/>
<local:ExitBtn x:Name="exitBtn" Margin="0,2.5,2.5,0" Height="15" VerticalAlignment="Top" HorizontalAlignment="Right" Width="15" MouseLeftButtonUp="ExitBtn_Click"/>
<local:MinBtn x:Name="minimizeBtn" Margin="0,2,37,0" HorizontalAlignment="Right" Width="15" Height="15" VerticalAlignment="Top" MouseLeftButtonUp="MinBtn_Click"/>
<local:MaxBtn x:Name="maximizeBtn" Margin="0,2,20,0" HorizontalAlignment="Right" Width="13" Height="15" VerticalAlignment="Top" MouseLeftButtonUp="MaxBtn_Click"/>
<local:ResBtn x:Name="resizeBtn" Margin="0,2,20,0" HorizontalAlignment="Right" Width="15" Height="15" VerticalAlignment="Top" Visibility="Hidden" MouseLeftButtonUp="ResBtn_Click"/>
<DataGrid Margin="10,25,10,10" Background="Black" BorderBrush="{x:Null}" HorizontalGridLinesBrush="White" VerticalGridLinesBrush="White" AlternatingRowBackground="#FF575656" RowBackground="#FF403C3C" Cursor="Cross"/>
<Expander Header="Menu" HorizontalAlignment="Left" Margin="-5,-17,0,0" Width="100" FontSize="10" RenderTransformOrigin="0.5,0.5" Height="332" VerticalAlignment="Top" BorderBrush="White" Background="Black" Foreground="#FFFFFEFE">
<Expander.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="0.9" ScaleX="0.9"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Expander.RenderTransform>
</Expander>
</Grid>
UPDATE 2: screenshot: https://ibb.co/iN2n7F Screenshot of Answer: https://ibb.co/c3BHra
ANSWER: Issue is something with my display only. Haven't figured it out yet, but the program operates as expected on another PC. Many thanks to @Vanna who helped me parse that out.