Cannot set AppBarButton Icon from Style
See original GitHub issueHi @Kinnara,
thank you for all your work on this great library!
I tried to define a Style
for an AppBarButton
that speciffes the AppBarButton.Icon
property.
Apparently, the Style only works on a single instance of the button.
If multiple buttons apply the same style, then only the last button will display the icon.
The Icon
property is of type IconElement
: FrameworkElement
.
AFAIK, an element can only be used once in the visual tree.
I haven’t been able to find a workaround for this current limitation.
Usually, control properties are either Freezable
or a pair of { Content, ContentTemplate }, to allow templating.
Maybe the new IconSource
provides an elegant solution to this problem?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How to change AppBarButton circle and icon color ...
I want to customize the circle and icon color of AppBarButton so far I tried following style but it does not work. In...
Read more >Style not applied inside MenuFlyoutItem.Icon · Issue #1217
Describe the bug I'd like to apply a style for all SymbolIcon elements of my app, but it seems that this is not...
Read more >XAML AppBarButton Bottom Border disapears by changing ...
You know why the border bottom disapears by changing the height under 40 ? Where in the Style can i change the values...
Read more >Making app bar button larger - Icon doesn't show when in ...
Hi Kmm,. Group the icon and the app bar together then go to “Edit Styles” then fix it to the top.
Read more >Using vector data for AppBar icons in XAML
I set my Button to use the base style, then set my label (via AutomationProperties.Name) and the Content is the exported vector data...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is actually possible in WPF, thanks to the x:Shared attribute:
Hi @Kinnara , thank you for your feedback.
Indeed, the issue is related to resource sharing. I am aware of the
x:Shared
attribute, it fixes the problem for global resources declared in XAML.In this case, I was trying to provide the icon resource in a Style through a (custom) markup extension that returns a (custom)
FontIcon
, programmatically. The markup extension would need to return a separate FontIcon instance for each target control that the style is applied to, similar tox:Shared
behavior. Maybe this is possible by hooking the target control from the markup extension, but I didn’t explore any further.Nonetheless, I understand the motivations for this library to stay close to the original UWP interface and I’m perfectly happy w/o support for
AppBarButton
styling.Thanks for all you hard work, guys. This library provides great UI improvements that are happily received by our app users. Quite amazing to see WinUI design running on an old Windows 7 (!) machine.
Kudos and keep it up!