MaterialDesignInXAML / MaterialDesignInXamlToolkit

Google's Material Design in XAML & WPF, for C# & VB.Net.
http://materialdesigninxaml.net
MIT License
15.04k stars 3.41k forks source link

Glitch with controls inside cards #2907

Open Imadlekal opened 1 year ago

Imadlekal commented 1 year ago

Bug explanation

It appears that there is a visual glitch whenever a certain controls are clicked on dark theme (when they're inside a card).

An example:

 <Button  Grid.Row="3"  ToolTip="Actualiser"
                                                     Width="24" Height="24"  Command="{Binding RefreshCommand}" Style="{StaticResource MaterialDesignToolForegroundButton}" >
            <materialDesign:PackIcon Visibility="{Binding ElementName=DemoItemsListBox, Path=SelectedItem.AddButton}" HorizontalAlignment="Center" VerticalAlignment="Center" Kind="Refresh"  Width="24" Height="24"></materialDesign:PackIcon>
        </Button>

Results (when inside a card):

P2FCXguasE

Results (when I put the exact same code outside of the card):

nVxHWSuinA

Same thing with a DataGridView when it's inside the card (it's not that apparent, but you can see the glitch on the left side of the sort arrow:

X332xQt42Y

This also happens with the Light theme switched ON.

What could be the problem here? I'm suspecting its the window hosting this UserControl, but I'm not sure where to start looking. If I host these buttons on a dialog, or something, they work just fine.

Version

4.5.0

Keboo commented 1 year ago

Interesting, the last time I saw this was with the ripple control inside of a tab header. I suspect it is related to that, but will need to look into it.

ElieTaillard commented 1 year ago

Looks similar to https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/issues/2308

Imadlekal commented 1 year ago

I'm still not sure what the problem is exactly, but I no longer have the glitch after uninstalling MahApps.

I wasn't using any of their components, except for the MetroWindow.

Erapchu commented 1 year ago

Do you have repo with this bug?

Nobody84 commented 1 year ago

Got the same behaviour. I'm using MaterialDesignThemes Package 4.6.1

I'm currently very busy, but maybe I'm able to create a repo with the bug this week.

Asivaprasadam commented 1 year ago

@Imadlekal, This might be a UI caching issue on WPF.

I had a similar problem and this is how I was able to resolve it. Can you try adding this code after InitializeComponent() in MainWindow.xaml.cs Constructor and see if it resolves the issue!

/*
 * TLDR: Removes random lines being drawn at grid borders.
 *
 * Ref: https://stackoverflow.com/questions/16177358/wpf-poor-rendering-of-application
 * Try disabling GPU acceleration: RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
 * Sometimes WPF GPU caching does a lot of tricks, and this can help, without degrading much performance IMO.
 */
RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.Default; // <--- Most Relevant