Skip to content

How i can override Selector="Button:pointerover /template/ ContentPresenter" at runtime? #18037

Answered by GamingCity
GamingCity asked this question in Q&A
Discussion options

You must be logged in to vote

I ended up doing it this way. Once i found the the documentation

Style style = new Style(x => x.OfType<Button>().Class(":pointerover").Template().OfType<ContentPresenter>());
if(config.MouseOverBackgroundHexColor != null)
{
    style.Setters.Add(new Setter(Button.BackgroundProperty, SolidColorBrush.Parse(config.MouseOverBackgroundHexColor)));
}
if(config.MouseOverForegroundHexColor != null)
{
    style.Setters.Add(new Setter(Button.ForegroundProperty, SolidColorBrush.Parse(config.MouseOverForegroundHexColor)));
}
if (config.MouseOverBorderHexColer != null)
{
    style.Setters.Add(new Setter(Button.BorderBrushProperty, SolidColorBrush.Parse(config.MouseOverBorderHexColer)));
}
button.Style…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@GamingCity
Comment options

@rabbitism
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by GamingCity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants