.NET 6 apps have abnormal display of animations and hover styles

TheColdPot 1 Reputation point
2022-01-02T09:27:55.2+00:00

UPDATE: This problem also appears on: .NET Core 3.1, .NET 5, .NET 6, .NET Framework 3, .NET Framework 4

Look like all the developing WPF has the error :(

My WPF app is using .NET 6. It can't display EventTrigger styles correctly
And it happens every time I run the app. My .NET version: 6.0.101 (SDK)
My PC:
Windows 11 21H2 (22000.376)

Hardware | Content

-----------
| --------
CPU | Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz 2.59 GHz
RAM | 16.0 GB / 15.8GB avaliable
System | 64-bit OS, based on x64 CPU
Display | NVIDIA GeForce GTX 1660 Ti

GIF: (Don't care about Chinese; Watch the window's behavior)
This is an example (Not my app)
161734-recording.gif
This is the app ModernFlyouts using .NET 6.
Repo: https://github.com/ModernFlyouts-Community/ModernFlyouts
This is NOT an error od ModernFlyouts. Don't create issue.

Developer technologies | Windows Presentation Foundation
Developer technologies | C#
{count} votes

2 answers

Sort by: Most helpful
  1. Hui Liu-MSFT 48,676 Reputation points Microsoft External Staff
    2022-01-03T08:10:45.91+00:00

    If your question is about the button style of wpf in .NET 6, you could try to use it in your code.
    The following is an example of the style of Button in .Net SDK6.0.101.( Microsoft Visual Studio Professional 2022 (64-bit) Version 17.0.4)

    MainWindow.xaml:

    <Window.Resources>  
            <Style x:Key="MyStyle" TargetType="{x:Type Button}">  
                <Setter Property="BorderBrush" Value="Transparent"/>  
                <Setter Property="BorderThickness" Value="0 0 0 3"/>  
                <Style.Triggers>  
                    <Trigger Property="IsMouseOver" Value="True">  
                        <Setter Property="BorderBrush" Value="Orange" />  
                    </Trigger>  
                    <Trigger Property="IsPressed" Value="True">  
                        <Setter Property="BorderBrush" Value="Red" />  
                    </Trigger>  
                </Style.Triggers>  
            </Style>  
        </Window.Resources>  
        <Canvas>  
            <Button  Width="200" Height="100" Content="click" BorderThickness="2">  
                <Button.Style>  
                    <Style TargetType="Button" BasedOn="{StaticResource MyStyle}">  
                        <Setter Property="Template">  
                            <Setter.Value>  
                                <ControlTemplate>  
                                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">  
                                        <StackPanel Orientation="Vertical">  
                                            <Label HorizontalAlignment="Center">Add</Label>  
                                        </StackPanel>  
                                    </Border>  
                                </ControlTemplate>  
                            </Setter.Value>  
                        </Setter>  
                        <Style.Triggers>  
                            <Trigger Property="IsPressed" Value="True">  
                                <Setter Property="BorderBrush" Value="Green" />  
                            </Trigger>  
                        </Style.Triggers>  
                    </Style>  
                </Button.Style>  
            </Button>  
        </Canvas>  
    

    The result:
    161891-3.gif


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. TheColdPot 1 Reputation point
    2022-01-17T01:11:46.917+00:00

    [Answer from internet]

    tl;dr

    Rename/Delete ALL file named NahimicOSD.dll in your computer. If you are using a DELL computer, DELETE the following files:

    • C:\ProgramData\A-Volute\DellInc.AlienwareSoundCenter\Modules\ScheduledModules\NahimicOSD.dll
    • C:\ProgramData\A-Volute\DellInc.AlienwareSoundCenter\Modules\ScheduledModules\x64\NahimicOSD.dll ### Reference

    https://blog.walterlv.com/post/wpf-renders-wrong-because-of-nahimicosd-en.html


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.