How can I be able to see the taskbar when WindowStyle="None"
. I'm trying to have my own buttons (Close, Maximize, Minimize) by removing the actual window title bar and using a dll too remove the border. Easy to maintain and easy to put in my code would be greatly appreciated.
Asked
Active
Viewed 3,685 times
2
-
Possible duplicate of http://stackoverflow.com/questions/20941443/properly-maximizing-wpf-window-with-windowstyle-none . – Jun 12 '14 at 17:00
-
What's the code you're using to implement your Maximize button click? Also I think that "border" you said you're using a dll to remove is probably the Resize handle, and there's a property to remove it. I can't remember what it's called, but check the window's Resize properties – Rachel Jun 12 '14 at 17:36
1 Answers
0
One of the possible fix to do this is: to limit the max size of window. For example:
C# code:
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
if (WindowState == WindowState.Normal)
{
System.Drawing.Rectangle rec = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle).WorkingArea;
MaxHeight = rec.Height;
MaxWidth = rec.Width;
ResizeMode = ResizeMode.NoResize;
WindowState = WindowState.Maximized;
}
else
{
MaxHeight = double.PositiveInfinity;
MaxWidth = double.PositiveInfinity;
ResizeMode = ResizeMode.CanResize;
WindowState = WindowState.Normal;
}
}
}
You need to set maxsize just before changing of window state. Otherwise, in some cases it works wrong. Also don't forget about ResizeMode.
And xaml:
<Window x:Class="WpfApplication2.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" WindowStyle="None" Height="300" Width="300">
<Grid>
<Button Content="Button" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Width="75" Click="ButtonBase_OnClick"/>
</Grid>
</Window>

vasylysk
- 132
- 10