-
-
Notifications
You must be signed in to change notification settings - Fork 516
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
Using MahApps IconPacks for BackstageTabItem's icon #782
Comments
@punker76 How does that work for the icon packs? |
The IconsPack takes whatever color is set for foreground in the control in fact if i set Foreground="red" in Fluent:BackstageTabItem, the icon turns red while the text remains white - however i haven't figured out a way to bind Foreground to the text's color I assume it's using Fluent.Ribbon.Brushes.BackstageTabItem.Header.Foreground (from the name), but using this as DynamicResource in Foreground throws an exception that it can't convert it to the type of property Foreground. Using StaticResource seems to work but if then i change theme (between yellow and blue for exemple) it doesn't update |
@batzen How gets the icon ContentPresenter the Foreground? Fluent.Ribbon/Fluent.Ribbon/Themes/Controls/BackstageTabItem.xaml Lines 22 to 29 in b9dfac5
And what exactly does the ObjectToImageConverter ? If I understand this correct then it tries to convert the Icon property to an ImageSource?
|
The ContentPresenter should inherit it's foreground from the parent.
A lot. It tries to convert everything it gets to something that could be an image. I will try to reproduce the issue by including the icon packs in the showcase application and see what has to be done to get this working correctly. |
The issue is caused by the logical tree. |
@batzen That's quite an undertaking. I haven't looked at the code but wouldn't it be easier/faster to have BackstageTabItem.Foreground match the text color? Given changing the Foreground property currently affects the icon (but not the text), if the text color becomes bound to the control's Foreground property, and the Foreground property set to the correct resource in a dynamic way (in the template), this should be fixed without the need to support binding in the icon - it just inherits the control's Foreground as it does now. Or am I missing something? |
May have found something - am getting a bunch of errors so haven't been able to test it in file Themes\Controls\BackstageTabItem.xaml you have:
I am assuming changing that Foreground definition from BlackBrush to Fluent.Ribbon.Brushes.BackstageTabItem.Header.Foreground should solve the issue. Any reason for that beeing set to BlackBrush? |
The icon already supports bindings, but that prevents dependency property inheritance due to the bug in contentcontrol. BlackBrush turns to white in the dark theme and the inverse for WhiteBrush (it turns black in the dark theme). So changing that doesn't make sense 😉 |
After further investigation it turned out that adding the icon to the logical tree was the wrong part, so instead of having to implement more code i have to delete a lot of code that's not even required and never was... That part of the ribbon was written before i inherited it and thought the original authors had a reason to add the icon to the logical tree, but there is none i can think of. |
@537mfb just pushed the changes to develop. |
@537mfb I have to reopen this as not adding the icon to the logical tree causes issues when using bindings with |
@batzen that's ok wound changing the Or in alternative bind to the |
I want it work out of the box without have to apply any kind of workaround on the consumer side. Ensuring that everything adheres to the logical tree rules seems way easier than adding your suggested workaround to every control and telling people that if they are creating their own styles that they also have to apply that workaround in their custom styles/templates. ;-) |
Good point If i have any other ideias i'll pitch them here to get your feedback |
You misunderstood me. I already have a working solution on my machine. I just need to finish the unit tests. 😁 |
@537mfb I will fix/feature this on IconPacks itself, so that it use the inherited Foreground form the VisualParent. A workaround for this is to use a DataTemplate with the IconPack inside. |
Hi @punker76 - thanks for the reply Ok did a new test this makes it work - even if i change the theme live |
For whom reading this in future: As of now, this code makes tab content's default foreground color overridden by the given value. E.g. If |
Not sure if this is an issue or just something i'm missing
I'm using both Fluent.Ribbon and MahApps IconPacks for a project
I wan0t to use an element of IconPacks as the Icon for the backstage tabItems
Here's a sample:
<Fluent:BackstageTabItem Header="Settings" Icon={iconPacks:Material kind=Settings}" />
But while the header text shows in white (expected) the icon shows IN black (unexpected)
Is there a way to make the Icon color match the text color?
All examples i found use images rather then the IconsPack for these icons
Environment
The text was updated successfully, but these errors were encountered: