-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fixed Toolbar IconImageSource not updating with Binding Changes #27402
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
Conversation
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
newImageSource.SourceChanged += ((MenuItem)bindable).OnImageSourceSourceChanged; | ||
} | ||
|
||
void OnImageSourceSourceChanged(object sender, EventArgs e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't required. it's already done elsewhere (I'm quite sure)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@StephaneDelcroix , Yes, the ImageElement.SourceProperty
contains the implementation of the sourceChanged event in its callback. However, replacing the existing Source property with ImageElement.SourceProperty
results in an InvalidCastException at runtime. I referred to the Button.cs
file for implementing ImageElement.SourceProperty in MenuItem.cs
. The crash occurs because MenuItem is being converted to a VisualElement, whereas its base class is StylableElement
, not VisualElement
. In contrast, Button has VisualElement
as its base class. Therefore, I proceeded with implementing the current code changes in this file alone.
Issue Details
The toolbar item's FontImageSource Glyph is not reflecting changes when the bound property is updated in the ViewModel. The icon remains static despite property changes in the binding source.
Root Cause
The MenuItem class lacks an implementation to listen for source changes in the IconImageSource property. When the Glyph property changes in the bound FontImageSource, the MenuItem is not notified of this change.As a result, the visual update is not triggered in the UI
Description of Change
Implementing a source changed event listener for IconImageSource in the ImageSource call back. When the ImageSource changes are detected, manually triggering PropertyChanged for IconImageSource.This propagates the change through the UI update mechanism, ensuring the toolbar icon reflects the new state.
Validated the behaviour in the following platforms
Issues Fixed
Fixes #8295
Output
Before.mov
After.mov