Frage

I need to create a stripped background for a border which should look like this...

enter image description here

I tried following code its working as back ground,but when i try to use in inside a data template its displaying grey background instead of stripped.

<LinearGradientBrush StartPoint="0,0" EndPoint="1,1" SpreadMethod="Repeat">
   <GradientStop Offset="0" Color="White"/>
   <GradientStop Offset="0.5" Color="White"/>
   <GradientStop Offset="0.5" Color="Black"/>
   <GradientStop Offset="1" Color="Black"/>
   <LinearGradientBrush.RelativeTransform>
      <ScaleTransform ScaleX="0.01" ScaleY="0.01"/>
   </LinearGradientBrush.RelativeTransform>
</LinearGradientBrush>
War es hilfreich?

Lösung

The scale factor is based on percentage values. Let's say that you apply the brush to a Rectangle Width = 600, Height=600, then with a scaleX = 0.01 a stripe is ~6 pixels in width. But shrink the Rectangle size to Width=60, Height=60, and the stripe is ~0.6 pixels wide. With such small stripes, the background will look gray.

Since you didn't show your DataTemplate I can't tell what size your elements are.

If this is your issue, then use a binding to change the ScaleX,ScaleY values based on the size of the target element.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top