-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add Resources property to Application #462
Comments
Could you explain why exactly you want the second example to be possible? Would it be equivalent to the first example? Or is the problem that you just don't understand why |
I want to have And second reason is that this is pattern used in other frameworks, especially in WPF, that I find very convenient and useful. Finally this can be viewed as syntactic sugar, as you don't have to define style only for resource definition. Please also tell why it was moved to |
I'll start by explaining this. It's a long story, so be prepared for a read! In WPF, styles are added to When WPF looks up a style, if there is no In Perspex we have a CSS-like system where many styles can match a single control, and the order in which they're defined matters. Resource dictionaries are unordered, so immediately we've ruled out a system like WPF's. Now we could make resource dictionaries in Perspex ordered, but that means we'd have to search every object in every resource dictionary for styles. That would be bad for performance. So instead we store Perspex styles in a Now when you want to build a theme in WPF, you create a XAML file containing a So that's why they're there. |
I'll now address your issue:
Firstly, styles defined in Now let me explain why I think you shouldn't be using them ;) The reason style resources were introduced was to allow those resources to be overridden for a particular part of the UI. For example, you might want a flyout control in your window to use a dark style while the window uses the light style. If you just want a named brush for the whole of your application, I'd suggest just exposing a
In general, I agree with this article which says:
|
As an addendum: I know there are people who try to define their whole view layer in XAML, and say that using code-behind is bad. I always doubted that this was something to follow, but after implementing Perspex and knowing everything that goes on in the background of a XAML framework - I am positive that they are wrong. It's an incredibly verbose and wasteful (in terms of CPU) way to do things. You're are not breaking MVVM by writing code in your view layer. Use the tool that makes most sense, and in many many cases that tool is code, not markup. |
Add
Resources
property toApplication
so it can behave same as this:so it is possible to define resources like this:
The text was updated successfully, but these errors were encountered: