How to Override ride the Theme Brushes in code behind?

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 5 years ago by Clint David
Version: 14.2.0610
Avatar

I need to update the value of a particular theme brush in code-behind. In XAML it is like this :

<Border HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,5,5" Width="36" Padding="2"
BorderThickness="1" BorderBrush="DarkGray" Background="#7FFCFCFC" CornerRadius="3"
x:Name="myBorder">
<Border.Resources>
<LinearGradientBrush x:Key="{x:Static themes:AssetResourceKeys.ButtonBackgroundDefaultedBrushKey}"
StartPoint="0,0"
EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Transparent"
Offset="0" />
<GradientStop Color="Transparent"
Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Resources>

</Border>

 

What is its equilavent in code behind?

Thanks,

Clint

Comments (1)

Posted 5 years ago by Clint David
Avatar

ah nevermind, i figured it out.

myBorder.Resources.Add(AssetResourceKeys.ButtonBackgroundPressedBrushKey, newBrush);

The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.