MaterialDesignInXamlToolkit icon indicating copy to clipboard operation
MaterialDesignInXamlToolkit copied to clipboard

Glitch with controls inside cards

Open Imadlekal opened this issue 2 years ago • 6 comments

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

Imadlekal avatar Oct 10 '22 08:10 Imadlekal

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.

Keboo avatar Oct 12 '22 17:10 Keboo

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

ElieTaillard avatar Oct 12 '22 19:10 ElieTaillard

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.

Imadlekal avatar Oct 22 '22 17:10 Imadlekal

Do you have repo with this bug?

Erapchu avatar Nov 29 '22 03:11 Erapchu

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.

Nobody84 avatar Nov 29 '22 14:11 Nobody84

@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

Asivaprasadam avatar Mar 07 '23 04:03 Asivaprasadam