需要帮助将XAML转换为C#代码?

Ran*_*ath 1 c# xaml

<!-- Base color -->
    <Ellipse Width="24" Height="24" Margin="10">
        <Ellipse.Fill>
            <RadialGradientBrush GradientOrigin=".5,.8" RadiusX="0.6">
                <GradientStop Color="#002255" Offset="1" />
                <GradientStop Color="#00eeff" Offset="0" />
            </RadialGradientBrush>
        </Ellipse.Fill>
    </Ellipse>
    <!-- Highligh color-->
    <Ellipse Width="18" Height="15" Canvas.Top="1" Canvas.Left="3" Margin="10">
        <Ellipse.Fill>
            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                <GradientStop Color="#ffffff" Offset="0" />
                <GradientStop Color="Transparent" Offset="1" />
            </LinearGradientBrush>
        </Ellipse.Fill>
    </Ellipse>
Run Code Online (Sandbox Code Playgroud)

Rob*_*vey 5

我给你举个例子.

这个:

<Rectangle Width="200" Height="100">
  <Rectangle.Fill>
    <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
      <GradientStop Color="Yellow" Offset="0.0" />
      <GradientStop Color="Red" Offset="0.25" />
      <GradientStop Color="Blue" Offset="0.75" />
      <GradientStop Color="LimeGreen" Offset="1.0" />
    </LinearGradientBrush>
  </Rectangle.Fill>
</Rectangle>
Run Code Online (Sandbox Code Playgroud)

相当于:

Rectangle rectangle = new Rectangle();
rectangle.Width = 200;
rectangle.Height = 100;

// Create a diagonal linear gradient with four stops.   
LinearGradientBrush brush = new LinearGradientBrush();
brush.StartPoint = new Point(0,0);
brush.EndPoint = new Point(1,1);
brush.GradientStops.Add(new GradientStop(Colors.Yellow, 0.0));
brush.GradientStops.Add(new GradientStop(Colors.Red, 0.25));                
brush.GradientStops.Add(new GradientStop(Colors.Blue, 0.75));        
brush.GradientStops.Add(new GradientStop(Colors.LimeGreen, 1.0));

// Use the brush to paint the rectangle.
rectangle.Fill = brush;
Run Code Online (Sandbox Code Playgroud)

http://msdn.microsoft.com/en-us/library/system.windows.media.lineargradientbrush.aspx