Reputation: 25938
How do you refer/use a static class variable as a XAML attribute value?
For example; AppConstants.cs
public class AppConstants {
public static readonly Color TextColor = Color.FromHex("aaaaaa");
}
HomePage.xaml (the below code is invalid)
....
<Button TextColor="AppConstants.TextColor"/>
....
What is the correct syntax to 'reference' AppConstants.TextColor
inside the attribute TextColor
?
Upvotes: 0
Views: 991
Reputation: 737
Try the x:Static Markup Extension
Generic code:
<object property="{x:Static prefix:typeName.staticMemberName}" .../>
Specific example:
<Button TextColor="{x:Static AppConstants.TextColor}"/>
Upvotes: 3