-
Couldn't load subscription status.
- Fork 117
Lower the opacity of a BitmapIcon when card is Disabled #732
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
|
Hi @niels9001! Just a suggestion. To keep it flexible, we could also implement this in the <x:Double x:Key="SettingsCardHeaderDisabledOpacity">0.6</x:Double><Setter Target="PART_HeaderIconPresenterHolder.Opacity" Value="{StaticResource SettingsCardHeaderDisabledOpacity}" />
|
|
@AndrewKeepCoding Fair, but we don't check if it's a bitmapicon in that visual state. And we don't want to change the Foreground AND setting the opacity. And we'd want to keep the Foreground on non-image elements to be consistent with other controls and meeting accessibility requirements (e.g. High Contrast themes). The alternative would be creating a second disabled state? |
|
I confirmed that an approach like this works. <VisualStateGroup x:Name="BitmapIconHeaderStates">
<VisualState x:Name="EnabledBitmapIconHeader" />
<VisualState x:Name="DisabledBitmapIconHeader">
<VisualState.Setters>
<Setter Target="PART_HeaderIconPresenterHolder.Opacity" Value="{StaticResource SettingsCardHeaderDisabledOpacity}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup> |
Yeah, you're right.. that is a more maintainable option :). Updated the code, please have a look! |
|
Nit: we could also clean up a few lines: - using System.ComponentModel.Design;- IsEnabledChanged += OnIsEnabledChanged;
+ IsEnabledChanged += OnIsEnabledChanged;- // e.Handled = true; |
Co-Authored-By: Andrew KeepCoding <andrewkeepcoding@gmail.com>
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.
My bad I missed this earlier. Since IsEnabled is checked, we should also refresh the visual state here just to be consistent.
private void CheckInitialVisualState()
{
VisualStateManager.GoToState(this, IsEnabled ? NormalState : DisabledState, true);
if (GetTemplateChild("ContentAlignmentStates") is VisualStateGroup contentAlignmentStatesGroup)
{
contentAlignmentStatesGroup.CurrentStateChanged -= this.ContentAlignmentStates_Changed;
CheckVerticalSpacingState(contentAlignmentStatesGroup.CurrentState);
contentAlignmentStatesGroup.CurrentStateChanged += this.ContentAlignmentStates_Changed;
}
// The Disabled visual state will only set the right Foreground brush, but for images we need to lower the opacity so it looks disabled.
if (HeaderIcon is BitmapIcon)
{
VisualStateManager.GoToState(this, IsEnabled ? BitmapHeaderIconEnabledState : BitmapHeaderIconDisabledState, true);
}
}|
@niels9001 want to address Andrew's last comment? Then I think we're good (though we need to fix CI as GHA runner updated again breaking us... 😭) |
|
Ah yes,, thanks @AndrewKeepCoding ! |
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.
Looks good to me.🙂
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.
Tested locally, fix works as intended with no side effects.
|
Re-running job, intermittent RichSuggestBox failure on WinUI 3. FYI @Arlodotexe #589, as I've been mentioning we should disable these specific tests for now (at least on WinUI 3). |

Fixes: #731
PR Type
What kind of change does this PR introduce?
Bugfix
What is the current behavior?
What is the new behavior?
PR Checklist
Please check if your PR fulfills the following requirements:
Other information