Button renders wrong after mouse leave
- .NET Core Version: 3.0 preview 5
- Windows version: 1803 build 17134.765
- Does the bug reproduce also in WPF for .NET Framework 4.8?: ~I don't know.~ It works fine on 4.6/4.7 and 4.8
Problem description: With this XAML:
<Window x:Class="RetailEntertainment.Zorgstand.SignIn.Desktop.Views.AddNewConnectionWindow"
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:RetailEntertainment.Zorgstand.SignIn.Desktop.Views"
xmlns:vms="clr-namespace:RetailEntertainment.Zorgstand.SignIn.Desktop.ViewModels"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance vms:AddNewRegistrationDialogViewModel}"
Title="New registration" Width="400" Height="100">
<StackPanel>
<TextBlock Text="Entert the connection string received from the portal:" />
<TextBox Text="{Binding ConnectionString}" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="Cancel" Margin="4" Padding="2" Command="{Binding CloseDialogCommand}"/>
<Button Content="Save" Margin="4" Padding="2" Command="{Binding TestAndAddRegistrationCommand}"/>
</StackPanel>
</StackPanel>
</Window>
The buttons render wrong after mouse leaves.
Before:
After:

Actual behavior: It looks like the button renders as if it has its parent size. After resizing the window, it renders normally again.
Expected behavior: No weird rendering
Minimal repro: Code is above
I run your code but work fine in .NET Framework 4.8.
Minimum Repo:
https://github.com/lindexi/lindexi_gd/tree/7ec17c839ae8b07b3847245ced022a33e4d66f60/Nelirakuurkykeanrke
It run in .NET Framework 4.8.
https://github.com/lindexi/lindexi_gd/blob/7ec17c839ae8b07b3847245ced022a33e4d66f60/Nelirakuurkykeanrke/Nelirakuurkykeanrke/Nelirakuurkykeanrke.csproj#L11
Could you add some code in your AddNewConnectionWindow.xaml.cs ?
Let me add some information: My laptop had an Intel i7 with integrated graphics and a Nvidia 1050 GPU.
To me it looks like that during drawing some framebuffers or textures are messed up, or wrong ones are used.
I tried this on another PC at work. There it shows the correct behavior.
Throwing this bug in the category that depends on the environment it runs on.
@jorisvergeer Could you find if some drivers are not installed on your device?
As far as I am aware, I have all drivers installed. I was able to play some games last night.
Are there any commands or tools I can run on my PC to diagnose the drawing? Or to debug the whole .net wpf drawing code.
Anyway, What I guess that happend om my machine it this:
(Approximation with Paint)
It wants to draw this:
Accidently draws a button on with its parents (or window, they are the same) size (I saw something like this on one occasion when switching windows):
Then only draws the portion in the buttons region:

Are there any commands or tools I can run on my PC to diagnose the drawing? Or to debug the whole .net wpf drawing code.
Yes, the Performance Profiling Tools for Windows Presentation Foundation may help you to find the dirty region.
@lindexi That tool does not seem to work with dotnet core 3.0 WPF
@jorisvergeer The tool works fine with .NET Core 3.0 WPF application. I've tested it a few weeks ago.
I wrote a post for my demo and you may read the English translated version:
@walterlv @lindexi You are right. But you have to have the "Perforator" tab open. Otherwise it doesn't work.
I'll try it when I get home.
Possibly related to https://github.com/dotnet/wpf/issues/319
@0xd4d Its probably related.
I don't know if it is worth anything:
- If I tick "Disable dirty region support" or "Show dirty-region update overlay", then it renders just fine.
- If I tick "Clear back-buffer before rendering" and then hover over a button, then the content of the window turns black, except for the button which renders correctly.
Edit: This is the same as in framework 4.8 so i guess it is normal. - Any other checkdox has no noticable effect, it kept rendering wrong.
Just captured another fun example:

I guess that somewhere, somehow, some active framebuffery-kind objects are being reused, leaked or mixed up.
@jorisvergeer what's your screen resolution and scale factor? Are you using multiple monitors?
@stevenbrix My laptop has 1920x1080 as resulution is uses the default scale factor. My laptop is of type MSI GF63 8RD
A maybe interesting detail is that is one of those laptops which has dual graphics card. intel and nvidia
I doubt that its got anything to do with DPI/resolution, that would probably keep aspect ratio and not just stretch the image to the window size. Probably more likely something to do with drivers/hardware. The other issue linked above #319 (closed as duplicate) was also reproduced on an integrated intel chipset.
Doesn't WPF have a way to force software rendering? Google finds things like this, if these work in .NET Core maybe someone who can reproduce the problem can check if it goes away when forcing WPF to render in software.
