Skip to content

Subscribes to the property chain upto the application for theme binding. - #8957

Closed
AmrAlSayed0 wants to merge 4 commits into
dotnet:mainfrom
AmrAlSayed0:fix-8713
Closed

AmrAlSayed0 wants to merge 4 commits into
dotnet:mainfrom
AmrAlSayed0:fix-8713

Conversation

@AmrAlSayed0

@AmrAlSayed0 AmrAlSayed0 commented Jul 23, 2022 •

Copy link
Copy Markdown
Contributor

Description of Change

Changed AppThemeBinding to subscribe to the changes happening to the property chain up to the parent application so that the target theme is always in sync with the current AppTheme

Issues Fixed

Fixes #8713

@jfversluis jfversluis added the community ✨ Community Contribution label Jul 24, 2022
@rmarinho

rmarinho commented Jul 25, 2022 •

Copy link
Copy Markdown
Member

/azp run

@rmarinho
rmarinho requested a review from PureWeen July 25, 2022 11:07
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@jfversluis

Copy link
Copy Markdown
Member

Thanks for your contribution @AmrAlSayed0 ! I see there are some build errors for this one unfortunately:

/Users/builder/azdo/_work/2/s/src/Controls/src/Core/AppThemeBinding.cs(11,20): error CS0169: The field 'AppThemeBinding._targetProperty' is never used [/Users/builder/azdo/_work/2/s/src/Controls/src/Core/Controls.Core.csproj]

@AmrAlSayed0

Copy link
Copy Markdown
Contributor Author

"never used" is usually a warning not an error so warning as errors is probably turned on but anyway, I will repush another change fixing this soon.

@AmrAlSayed0

Copy link
Copy Markdown
Contributor Author

@jfversluis Done.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@PureWeen PureWeen self-assigned this Feb 13, 2023
@jfversluis jfversluis added the area-theme Themes, theming label Feb 13, 2023
@PureWeen

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your pull request. We are auto-formating your source code to follow our code guidelines.

@StephaneDelcroix StephaneDelcroix left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a unit test that'd fail without your changes, and pass with it? Thx

@PureWeen

Copy link
Copy Markdown
Member

@AmrAlSayed0 I know it's been a while so just let us know if you'd like us to take this PR over from you or if you still would like to work on it.

@AmrAlSayed0

Copy link
Copy Markdown
Contributor Author

@PureWeen Yes, I submitted this at a time when I had some free time but now, sadly, I don't. Please tell me if there is anything I can do to give you the access or something. I don't know what taking over actually involve 😅

}

void OnRequestedThemeChanged(object sender, AppThemeChangedEventArgs e)
=> ApplyCore(true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this generate on background threads? I'm wondering if we should have a version of this that always fires on the UIThread. Otherwise, every single AppThemeBinding is going to dispatch changes individually. If we just ensure that on Window there's a version of this (or maybe this one already does) that fires on the UIThread then all the AppThemeBindings changes can just happen at once.


void OnWindowChanging(object sender, PropertyChangingEventArgs e)
{
if (string.Equals(e.PropertyName, VisualElement.WindowProperty.PropertyName, StringComparison.Ordinal))

@PureWeen PureWeen Feb 17, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call DetachEvents from WindowChanging and ApplicationChanging? Or does Unapply run when that happens?

@PureWeen

Copy link
Copy Markdown
Member

@AmrAlSayed0 sounds good! Thank you for the PR and apologies it took so long to get back to you on this. We can just take it over. No need to do anything.

@PureWeen
PureWeen marked this pull request as draft February 17, 2023 16:06
@samhouts samhouts added this to the Under Consideration milestone Aug 15, 2023
@samhouts samhouts added the stale Indicates a stale issue/pr and will be closed soon label Sep 11, 2023
@PureWeen

PureWeen commented Feb 4, 2024

Copy link
Copy Markdown
Member

Closing in favor of #19931

@PureWeen PureWeen closed this Feb 4, 2024
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 6, 2024
@samhouts samhouts removed this from the Under Consideration milestone Jul 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-theme Themes, theming community ✨ Community Contribution stale Indicates a stale issue/pr and will be closed soon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rework AppThemeBinding to use IApplication and/or Window.Parent

6 participants