Skip to content

UiApplication to fix Application.Current null#851

Merged
pomianowski merged 11 commits intolepoco:developmentfrom
ricaun:development-uiapplication
Feb 4, 2024
Merged

UiApplication to fix Application.Current null#851
pomianowski merged 11 commits intolepoco:developmentfrom
ricaun:development-uiapplication

Conversation

@ricaun
Copy link
Copy Markdown
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.

@ricaun ricaun requested a review from pomianowski as a code owner December 2, 2023 01:41
@github-actions github-actions Bot added the PR Pull request label Dec 2, 2023
@ricaun
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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
@ricaun
Copy link
Copy Markdown
Contributor Author

ricaun commented Feb 4, 2024

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

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Feb 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

PR Pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants