Search code examples
c#xamlsilverlight

Hatch patterns in XAML silverlight


I want to fill the remaining portion of the texbox with hatch patterns (diagonal line) using XAML for silverlight. I know the Silverlight is out of date and not in support. But i have a code which i need to fix. I am not sure how to implement the hatch patterns without VisualBrush as we do for WPF.

I tried with Linearbrush, but unable to implement it

<LinearGradientBrush x:Key="DiagonalLine" EndPoint="0,0" StartPoint="8,8" 
                     MappingMode="Absolute" SpreadMethod="Repeat">
    <GradientStop Color="Black" Offset="0" />
    <GradientStop Color="Black" Offset="0.1" />
    <GradientStop Color="White" Offset="0.1" />
    <GradientStop Color="White" Offset="1" />
</LinearGradientBrush>

Solution

  • I tried the below code and it works

     <Rectangle Grid.Column="1" Margin="10,0,0,0" Stroke="{Binding Appointment.BorderAppointmentBackground}"
                               StrokeThickness="2">
                        <Rectangle.Fill>
                            <LinearGradientBrush MappingMode="Absolute" SpreadMethod="Repeat"
                                                 StartPoint="0,0" EndPoint="5.0, 5.0">
                                <GradientStop Color="{Binding Appointment.BorderAppointmentBackground}"/>
                                <GradientStop Color="{Binding Appointment.BorderAppointmentBackground}" Offset="0.1"/>
                                <GradientStop Color="#FFFFFFFF" Offset="0.3"/>
                                <GradientStop Color="#FFFFFFFF" Offset="0.3"/>
                            </LinearGradientBrush>
                        </Rectangle.Fill>
                    </Rectangle>