AllowTransparency makes the maximum possible

I am currently making a media player using WPF and am facing a problem.

I want the layout to have no regular window borders and shadow. I did this by setting WindowStyle = none and AllowTransparency = true. All this works very well if I do not want to use it in full screen mode. As soon as I try to configure WindowState to maximize, it fades out like crazy (it cuts off all edges). This is apparently caused by the AllowTransparency = true part. If I return its value false, the maximized part will work as intended. Unfortunately, I cannot install AllowTransparency after launching the application. I can compensate for this somewhat by using the border and adjusting it, but actually it does not look right, and I'm not sure that it will work at different resolutions.

So to summarize:

  • Is it possible to maximize WindowState's performance, as usual, with AllowTransparency = true?
  • Or there is another way to make a window not have a normal window border without setting AllowTransparency = true
  • Or is there a better way to make an application full screen?

Does anyone have a solution or idea to accomplish this?

+4
source share
2 answers

You sent a response to the MSDN forum, but not here, so here it is:

The solution is to set ResizeMode = NoResize when switching to full screen mode. It seems that AllowTransparency = True still has a regular border from the window, but just hides it, so when you maximize it, it tries to compensate for that border. But if you change the ResizeMode, the border will go away.

https://social.msdn.microsoft.com/Forums/vstudio/en-US/0b938537-c048-4122-8a2f-29d04d21f2df/allowtransparency-in-fullscreen?forum=wpf

+2

:

AllowsTransparency = "True"

WindowStyle = "None"

, .

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;
}
0

Source: https://habr.com/ru/post/1568770/


All Articles