Skip to content
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

UiApplication to fix Application.Current null #851

Merged
merged 11 commits into from
Feb 4, 2024

Conversation

ricaun
Copy link
Contributor

@ricaun ricaun commented Dec 2, 2023

Pull request type

Please check the type of change your PR introduces:

  • Update
  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

What is the current behavior?

If the Application.Current is null the Wpf.Ui library does not work, too many Application.Current are hard coded.

Swap Application.Current with a custom class UiApplication.Current gonna fix the issue and gonna work the same if Application.Current is not null.

Issue reference: #837

What is the new behavior?

  • Nothing gonna change if the Application.Current is not null in the main application.
  • If is null the main application can add the resources manually in the Window/Page and make the theme works. (There is an implementation in the Wpf.Ui.Demo.Console, the idea is to create some ApplyResourses in the Wpf.Ui in the next PR.)

Other information

This PR has a project with a simple implementation when the Application.Current is null, a console application creates a simple View with the Theme.

@github-actions github-actions bot added the PR Pull request label Dec 2, 2023
@ricaun
Copy link
Contributor Author

ricaun commented Dec 2, 2023

I added the ApplicationThemeManager.Apply(frameworkElement) method to help add/update the resources in the frameworkElement.

@RichardWhitfield
Copy link

Just as a comment I can confirm this works when using WPF-UI in a plugin context where the UI controls are in a project outside of the runtime resolved assembly (if the UI controls are in the same assembly then you can simply add an app.xaml file to the root with the standard resources.

@CodorStelian
Copy link

CodorStelian commented Jan 31, 2024

Nice work 👏
I don't know why, but scrollbar is not themed in NavigationView. Just remove ScrollViewer.CanContentScroll="False" from DashboardPage.xaml to reproduce this bug.
Update: I found a way to fix this by using ScrollViewer in DashboardPage.xaml along with ScrollViewer.CanContentScroll="False".
Screenshot 2024-01-31 022600

@pomianowski pomianowski merged commit 437d92b into lepoco:development Feb 4, 2024
1 of 2 checks passed
@ricaun
Copy link
Contributor Author

ricaun commented Feb 4, 2024

Nice 🤗
Are you planing to create a new prerelease soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR Pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants