Windows Phone 8.1 Ellipse Rectangle Brush

network | | 访问(36)
<StackPanel>
    <Ellipse Height="82" x:Name="ellipse1" StrokeThickness="1" Width="300" Stroke="White"></Ellipse>
    <TextBlock Height="96" x:Name="textBlock1" Text="TextBlock" FontSize="80" HorizontalAlignment="Left" />
    <Rectangle Height="124" HorizontalAlignment="Left" x:Name="rectangle1" Stroke="White" StrokeThickness="1" Width="327"/>
    <Ellipse Height="161" HorizontalAlignment="Left" x:Name="ellipse2" Stroke="White" StrokeThickness="1" Width="200"/>
</StackPanel>
public sealed partial class MainPage: Page {
    public MainPage() {
        this.InitializeComponent();
        //使用SolidColorBrush填充椭圆
        ellipse1.Fill = new SolidColorBrush(Colors.Blue);
        //使用LinearGradientBrush来设置文本框的背景
        LinearGradientBrush l = new LinearGradientBrush();
        l.StartPoint = new Point(0.5, 0);
        l.EndPoint = new Point(0.5, 1);
        GradientStop s1 = new GradientStop();
        s1.Color = Colors.Yellow;
        s1.Offset = 0.25;
        l.GradientStops.Add(s1);
        GradientStop s2 = new GradientStop();
        s2.Color = Colors.Orange;
        s2.Offset = 1.0;
        l.GradientStops.Add(s2);
        textBlock1.Foreground = l;
        //使用ImageBrush来填充矩形
        ImageBrush i = new ImageBrush();
        i.Stretch = Stretch.UniformToFill;
        i.ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/StoreLogo.scale-100.png", UriKind.Absolute));
        rectangle1.Fill = i;
        //使用LinearGradientBrush来设置按钮的背景
        LinearGradientBrush rb = new LinearGradientBrush();
        GradientStop s3 = new GradientStop();
        s3.Color = Colors.Yellow;
        s3.Offset = 0.25;
        rb.GradientStops.Add(s3);
        GradientStop s4 = new GradientStop();
        s4.Color = Colors.Orange;
        s4.Offset = 1.0;
        rb.GradientStops.Add(s4);
        ellipse2.Fill = rb;
    }

    protected override void OnNavigatedTo(NavigationEventArgs e) {}
}