5 Answers, 1 is accepted
Hi Kathy,
What you can do to achieve this is to use LinearGradientBrush class and specify inside it GradientStop with a different color. For example, the below code snippet shows the LinearGradientBrush of the RadButton control in the default theme (Office_Black).
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#FFDCDCDC" Offset="0.50"/>
<GradientStop Color="#FFADADAD" Offset="0.50"/>
<GradientStop Color="#FFD4D4D4" Offset="1"/>
</LinearGradientBrush>
To apply this to all RadMenuItems you can use Implicit Style.
<Style TargetType="telerik:RadMenuItem" BasedOn="{StaticResource RadMenuItemStyle}">
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#FFDCDCDC" Offset="0.50"/>
<GradientStop Color="#FFADADAD" Offset="0.50"/>
<GradientStop Color="#FFD4D4D4" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
As a side note: If you are using NoXAML binaries, the BasedOn property needs to be set to the default style of the control. Otherwise, the implicit style will override the default one and the control will not appear.
Regards,
Dinko
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
Hello Kathy,
Can you elaborate on what you mean by "Is it possible to have both the crosshatch and the background color?"? Can you send me some pictures of the expected result? This will hopefully allow me to better understand the requirements and try to think of a suitable suggestion.
Looking forward to your reply.
Regards,
Vladimir Stoyanov
Progress Telerik
Hello Kathy,
Thank you for the shared pictures and the provided description.
Can you check out the following articles, where similar scenarios were discussed?
- Creating a Hatched / Patterned Brush in WPF
- Create a hatch pattern in WPF
To recap you can try the approach of using a VisualBrush to achieve the Background and the pattern at the same time.
I hope you find this helpful.
Regards,
Vladimir Stoyanov
Progress Telerik