-
-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gallery only shows items once, then shows blank? #910
Comments
That sounds really strange. |
The showcase application already contains a test case similar to your use case and it's working fine there. |
@batzen thank you very much for looking into this, I really appreciate your time & input. I've dug deeper and found out some more details. Because of memory leaks caused by binding to plain CLR objects (non-DOs, and without INotifyPropertyChanged) we registered a class handler for the Unloaded event which does this:
If I take this code out then the gallery never loses its contents, so this is definitely the cause. (And maybe its not a great fix). But it only seems to break the gallery... If I substitute a Watching the binding diagnostics I see lines like this when the gallery unloads:
I haven't seen messages like this for other controls. So I guess the question boils down to why the |
Having a class handler clearing all bindings on unload is a very bad idea. Instead of clearing all bindings it would be way better, and cleaner, to just implement
|
@batzen I've attached a solution which just reproduces the difference I noticed between ListBox and Fluent:Gallery. Steps to reproduce:
Variation 2:
I agree that clearing bindings is far from ideal. It was done as a workaround for another problem (*), but interestingly this was the only control (that I am aware of) which exhibited any change in behavior at all. So maybe its worth understanding why that is. (*) External classes without property change notification. Probably need to wrap them in new classes instead. |
Just had a look at your repro. |
Ok, it's a bug in WPF itself. This might also be interesting for your memory leak workaround. |
Interesting conclusion...! Do I understand correctly the following implications:
|
Not every control needs the loaded handler. In this case no one in the tree for the ListBox has a loaded handler, so the unloaded class event is not fired for anyone when closing the popup. The gallery on the other hand has a loaded handler, so the unloaded class event is fired for every control that's more up in the tree. So you get events for the gallery, some borders, some decorators and the popup. The above would also be true if someone directly handled the unloaded event and it does only not work when using a class event handler. The "offending" line is https://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/BroadcastEventHelper.cs,332 and the same in line https://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/BroadcastEventHelper.cs,393 I am not sure if everyone would calls this a bug in WPF. |
Thanks yet again for your clear explanation & help / time looking into this. Do you think it is worth reporting this on https://github.com/dotnet/wpf/issues ? At the very least it seems like this behavior should be documented (if they don't consider it a bug). For my purposes this issue is closed now, as obviously it is not caused by Fluent Ribbon at all. Best regards, |
You should report it there and mention me and this issue there. |
Summary - my galleries are only showing contents a single time. Hopefully someone here has seen this before... so I'll try to describe the problem briefly but can add more details or code if that's helpful.
I have a
Fluent:DropDownButton
which has several items in its contents including twoFluent:Gallery
objects.Each gallery has its
ItemSource
bound to anObservableCollection<Thing>
and each has anItemTemplate
/DataTemplate
forThing
.This is the strange behavior I'm trying to debug:
In the debugger I can see that the collections have not changed at all.
Gallery.HasItems = false
, and yetGallery.ItemsSource.Count
> 0 at the same time.So I'm fairly stumped at this... I've never seen any other
ItemsControl
have this behavior.It very well may not be an issue with Fluent:Ribbon at all, but I thought I should start here. Thank you!
Environment
The text was updated successfully, but these errors were encountered: