tags:

views:

30

answers:

1

Is there any way without using image to show horizontal or vertical lines in the Rectangle.

A: 

Yes you can easily do this with a LinearGradientBrush:

  <Rectangle Width="100" Height="100">
     <Rectangle.Fill>
        <LinearGradientBrush SpreadMethod="Reflect" StartPoint="0 0" EndPoint="0 0.05">
           <GradientStop Offset="0.5" Color="Black"/>
           <GradientStop Offset="0.5" Color="White"/>
        </LinearGradientBrush>
     </Rectangle.Fill>
  </Rectangle>

You control line thickness and orientation with the EndPoint property.

bitbonk
Thanks a lot.I am now working on showing a dotted line based on this, I wonder if its possible with this approach.
Pravin
You could do this by overlaying an opacity mask with a similar lineargradient brush (replace white with #00FFFFFF) that is perpendicular to the lines.
bitbonk
Thanks for the solution again but, now i guess i won't be able to use any of this as the width of the rectangle is going to change at runtime. So the gradientStop offets won't work in that case it won't look like lines.
Pravin