WPF BitmapCache is not completely cleared

We have a WPF page with a user control where we use BitmapCache - when we try to clear this element by updating the property (data binding) with an empty path (New Path ()), it is not completely updated / cleared. If I slightly resized the window, the area in which BitmapCache is active is completely cleared.

Is there anything special to clear / update an element that uses BitmapCache?

This is our code:

<me:ScrollViewer RenderedWaves="{Binding RenderedWaves}" ItemTemplate="{DynamicResource DataTemplateForWaveItem}" ItemsPanel="{DynamicResource ItemsPanelTemplateForWaveItems}" CacheMode="BitmapCache" /> 

I thought I fixed it, but it does not work every time ...

This path setting code does not immediately update BitmapCache:

 Protected WriteOnly Property SetGraph As Path Set(value As Path) If value Is Nothing Then value = GetEmptyPath() _graph = value OnPropertyChanged(New PropertyChangedEventArgs(PropertyNameGraph)) End Set End Property 

And this code sometimes updates it:

 Protected WriteOnly Property SetGraph As Path Set(value As Path) UIDispatcherLocator.UIDispatcher.Invoke(Sub() If value Is Nothing Then value = GetEmptyPath() _graph = value End Sub, Threading.DispatcherPriority.Background) OnPropertyChanged(New PropertyChangedEventArgs(PropertyNameGraph)) End Set End Property 
+6
source share
1 answer

Perhaps you just introduced a new event to the object to activate it when necessary, and when the caller will set the object = a new object that was created by the temporary use statement, if you could inherit it from system.idisposable or if you just set to null on completion? I don't know the code for it from the top of my head, but something like:

 MyEvent += new event(object b); event(object b) { using (custom_ScrollViewer = new custom_ScrollViewer) { OnScreen_ScrollViewer = Custom_ScrollViewer; }; // or custom_ScrollViewer = new custom_ScrollViewer; OnScreen_ScrollViewer = Custom_ScrollViewer; custom_ScrollViewer = null; } 
0
source

Source: https://habr.com/ru/post/922582/


All Articles