XAML silverlight中的图案填充模式

时间:2019-07-10 08:24:22

标签: c# xaml silverlight

我想用TextBoxXAML用填充图案(对角线)填充Silverlight的其余部分。我知道Silverlight已过时,无法获得支持。但是我有一个代码需要修复。我不确定如何像VisualBrush一样在没有WPF的情况下实现填充图案。

我尝试使用Linearbrush,但无法实现

<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>

1 个答案:

答案 0 :(得分:0)

我尝试了下面的代码,并且有效

 <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>