Skip to content

[C# Markup] How to create a binding to state that selects themed resource? #2319

Answered by rajamatt
kucint asked this question in Q&A
Discussion options

You must be logged in to vote

@kucint thanks for the details, creating two styles is definitely an option. This could be considered the best way of doing it because we avoid using converters with ThemeResources directly.

First approach

I went ahead and modified the sample you sent, firstly by adding the two Styles to your MyThemes class:

internal static class MyThemes
{
    public static readonly Resource<Brush> BrushA = ThemeResource.Create<Brush>(nameof(BrushA), new SolidColorBrush(Colors.Red), new SolidColorBrush(Colors.Orange));
    public static readonly Resource<Brush> BrushB = ThemeResource.Create<Brush>(nameof(BrushB), new SolidColorBrush(Colors.Blue), new SolidColorBrush(Colors.LightBlue));
 
    public static 

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@MartinZikmund
Comment options

Comment options

You must be logged in to vote
3 replies
@kucint
Comment options

@rajamatt
Comment options

Answer selected by MartinZikmund
@kucint
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants