2
Answers

how to define static resource for background color of wpf?

Sumit Kumawat

Sumit Kumawat

7y
486
1
hi all,
im writing LinearGradientBrush code in window.resource like below
<Window.Resources>
<LinearGradientBrush x:Key="cbColor">
<GradientStop Offset="0" Color="Red"></GradientStop>
<GradientStop Offset="0.5" Color="Silver"></GradientStop>
<GradientStop Offset="1" Color="Green"></GradientStop>
</LinearGradientBrush>
</Window.Resources>
and using this as a background of window as a static resource but it is giving some error.
and if am using it as a dynamic resource it working fine,im confused why it is not working with static resource as i am writing it only in window xaml code
Answers (2)