-
Notifications
You must be signed in to change notification settings - Fork 28
Markup Extensions in Css
David Rettenbacher edited this page Dec 9, 2017
·
3 revisions
Xaml supports markup-extensions to provide Xaml with values. The classic ones are
- Binding
- StaticResource
- DynamicResource
Markup-extensions can be invoked in css by writing #<name-of-markup-extension>
.
I.e. you have a button which you want to
- bind to the
Message
property of the binding-context (aka. data-context) - use the static resource named ApplicationBackgroundColor
- use the dynamic resource named CurrentFontSize then you can define the css like this:
Button {
Text: #Binding Message;
BackgroundColor: #StaticResource ApplicationBackgroundColor;
FontSize: #DynamicResource CurrentFontSize;
}
Alternatively you can surround the markup-extensions with quoutes (single- or double-quotes) to use the old Xaml-syntax:
Button {
Text: "{Binding Message}";
BackgroundColor: "{StaticResource ApplicationBackgroundColor}";
FontSize: "{DynamicResource CurrentFontSize}";
}