Transparent WPF Borders Force UI to Stop Redrawing

As a continuation of my previous question , I am wondering how to use transparent windows correctly. If I set my window to use transparency, the user interface will sometimes stop responding. In fact, what happens is that the user interface is simply not being updated as it should. Animation does not occur, pages are not displayed to move; however, if you watch the debugger click on buttons, links, etc., it really works. Minimizing and restoring the window again picks up the user interface, and the user can continue working until the behavior returns.

If you remove the transparent borders, the behavior will not occur. Am I doing something wrong or are there other settings, code, etc. Which I need to implement to work correctly with transparent borders?

Here is my window declaration for code that fails.

<Window x:Class="MyProject.MainContainer" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="WPF APplication" Height="600" Width="800" xmlns:egc="ControlLibrary" Background="{x:Null}" BorderThickness="0" AllowsTransparency="True" MinHeight="300" MinWidth="400" WindowStyle="None" > 

And code that doesn't show behavior

 <Window x:Class="MyProject.MainContainer" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="WPF Application" Height="600" Width="800" xmlns:egc="ControlLibrary" Background="{x:Null}" BorderThickness="0" AllowsTransparency="False" MinHeight="300" MinWidth="400" WindowStyle="None" > 
+2
source share
3 answers

I think I finally found a workaround. From all that I read, this problem should not occur with XP SP3 and .NET 3.5 SP1, but it is.

An example from this blog post shows how to use the Win32 API functions to create a window with an irregular shape, which is what I did. After processing my main window to use these methods, it seems that everything works as expected, and the behavior did not return.

It should also be noted that the reason why the author recommends this method is related to performance issues with WPF and transparent windows. Although I believe that in .NET 3.5 SP1 it may be better that it was not so difficult to implement and should work better.

+1
source

Are you using .NET 3.0 or .NET 3.5 for Windows XP Service Pack 2? If so, this is a known issue with the transparent window API, which was fixed in .NET 3.5 and SP3 for XP (and I think SP1 for Vista). Basically, when you set AllowsTransparency to True, the WPF pipeline should only display in software mode. This will result in significant performance degradation for most systems.

Unfortunately, the only thing you can fix is ​​upgrade to .NET 3.0 SP1 (included with .NET 3.5) and install the appropriate service pack for Windows. Note that transparent windows are even slower, but not so bad. You can find a more detailed discussion here .

+2
source

I work on Windows XP Pro SP3 and use .NET 3.5 SP1. I also confirmed that the project targets version 3.5 of the framework.

0
source

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


All Articles