WPF Rectangle ellipse

FredGrit發表於2024-06-30
<Window x:Class="WpfApp185.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp185"
        mc:Ignorable="d" WindowState="Maximized"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/> 
        </Grid.RowDefinitions>
        <Rectangle x:Name="rect" Stroke="Black" VerticalAlignment="Stretch" >
            <Rectangle.Fill>
                <LinearGradientBrush>
                    <GradientStop Offset="0" Color="Green"/>
                    <GradientStop Offset="0.5" Color="Cyan"/>
                    <GradientStop Offset="1" Color="Blue"/>
                </LinearGradientBrush>
            </Rectangle.Fill>
        </Rectangle>
        <Ellipse StrokeThickness="20" VerticalAlignment="Stretch" Stroke="Cyan"/>
    </Grid>
</Window>

相關文章