MaterialDesignInXAML / MaterialDesignInXamlToolkit

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

WPF UI Freezes after resuming from screen lock for slider #2473

Closed Divyesh-13 closed 2 years ago

Divyesh-13 commented 2 years ago

Hello,

In the application when screen lock after unlock application is freezes if slider is remove then application work normally

Erapchu commented 2 years ago

Hello. Please can you provide a bit more info about issue?

Divyesh-13 commented 2 years ago

I have a project with more then one Material Design WPF forms that will interact with each other. When I login to my first form it hides and the second form shows after I successfully logged in.

However when I perform a screen lock (Win+L) and resume my workstation, the UI freezes .

I found out that the trigger of this issue is the hiding of my first form because I tried commenting the Hide() function in my first form and it went well. I tried to pass the first instance of my form to the second to solve it but it didn't went well.

I also recreated the steps and applied it to your sample project and the result is very similar when I do screen lock.

Why is it that the 2nd form freezes when I call Hide() in my first form? Any solutions for this bug?

Erapchu commented 2 years ago

This is known issue related to WPF, not to material design xaml library. To resolve issue you need to explicitly close first window OR remove shadow cache (with ShadowAssist)

Erapchu commented 2 years ago

https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/issues/2377

Divyesh-13 commented 2 years ago

that thing already i tried but not working and implement at level of windows also but still ui freezes

Slider Grid.Column="1" Minimum="5" Maximum="20" Width="500" materialDesign:ShadowAssist.CacheMode="{x:Null}" HorizontalAlignment="Left" Value="{Binding SettingDetail.BeforeMaxLimit}"

Erapchu commented 2 years ago

You need to ensure that no any BitmapCache is used in all controls. Probably some control contains BitmapCache in style.

Erapchu commented 2 years ago

Ok, I found that slider contains BitmapCache directly in Style. To resolve it you need to copy style from https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/master/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Slider.xaml and remove ALL CacheMode setters. In that case slider only uses AdornerDecorator. So, you need to remove only

`

</AdornerDecorator.CacheMode>`

Erapchu commented 2 years ago

Apply this style to all other sliders after changes

Divyesh-13 commented 2 years ago

Hello , I am new to wpf can u help me I am using "MaterialDesignDiscreteSlider"

Divyesh-13 commented 2 years ago

after remove also same thing ui freezes

Erapchu commented 2 years ago

Probably some other controls uses bitmap cache too. To detect it you need to search over all controls in XAML of you window. You need to: 1) Find control with bitmapcache 2) Remove bitmapcache in style 3) Set that style to control

I can't help without more info. Please if you can send a link to project or send code here. Otherwise, you need just to find all controls with bitmapcache and remove them, see what's happens. Only MaterialDesignToolBar and Sliders use BitmapCache that cann't be controlled via ShadowAssist.CacheMode

Divyesh-13 commented 2 years ago

this is a demo project https://github.com/Divyesh-13/test

Erapchu commented 2 years ago

@Divyesh-13 please make this repository as public or check a link.

Divyesh-13 commented 2 years ago

Sorry now check click on login button and lock screen then try to change value for slider

Erapchu commented 2 years ago

This is a known issue https://github.com/Erapchu/GhostWindows You need to avoid hide WPF windows at all. You may close first window and open second one. The root of this behavior is BitmapCache

Divyesh-13 commented 2 years ago

ok thankyou