I'm currently making a media player using WPF and have come across a problem.
I want the layout to have no regular windows borders and a dropshadow. I have done this by setting WindowStyle=none and AllowTransparency=true. This all works very well, as long as I do not want to use it in fullscreen. As soon as i try to set WindowState to maximized, it overscans like crazy (it cuts off all the edges). This is apparently caused by the AllowTransparency=true part. If I set this back to false, the maximized part works as intended. Unfortunately I cannot set the AllowTransparency once the application is started. I can somewhat compensate this by using a border and adjusting the margin of that, but it doesn't really look right and I am not sure it will work on different resolutions.
So to sum up:
Does anyone have a solution or an idea to accomplish this?
You posted the answer on the MSDN forum, but not here, so here it is;
The solution is to set the ResizeMode=NoResize when going to fullscreen. It seems that the AllowTransparency=True still has the regular border from the window, but just hides it, so when you maximize it tries to compensate for that border. But if you change ResizeMode, the border goes away.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/0b938537-c048-4122-8a2f-29d04d21f2df/allowtransparency-in-fullscreen?forum=wpf
My solution works for :
AllowsTransparency="True"
WindowStyle="None"
You cannot set maximize, because it goes full screen.
if (window.Tag == null){
window.Tag = window.Width + ";" + window.Height + ";" + window.Left + ";" +
window.Top;
window.Width = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
window.Height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
window.Left = 0;
window.Top = 0;
window.WindowState = WindowState.Normal;
} else {
List<int> sizes = new List<int>(window.Tag.ToString().Split(';').Select(int.Parse));
window.Width = sizes[0];
window.Height = sizes[1];
window.Left = sizes[2];
window.Top = sizes[3];
window.Tag = null;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With