WPF resource use other resource

<Window x:Class="WpfApp184.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:WpfApp184"
        mc:Ignorable="d" WindowState="Maximized"
        Title="MainWindow" Height="450" Width="800">
    <Window.Resources>
        <LinearGradientBrush x:Key="brush1">
            <GradientStop Offset="0" Color="Green"/>
            <GradientStop Offset="0.5" Color="Cyan"/>
            <GradientStop Offset="1" Color="Blue"/>
        </LinearGradientBrush>
        <Style x:Key="rectStyle" TargetType="Rectangle">
            <Setter Property="Fill" Value="{StaticResource brush1}"/>
            <Setter Property="StrokeThickness" Value="10"/>
            <Setter Property="Stroke" Value="Red"/>
        </Style>
    </Window.Resources>
    <Grid>
        <Rectangle Style="{StaticResource rectStyle}" />
    </Grid>
</Window>

 

posted @ 2024-06-27 21:00  FredGrit  阅读(2)  评论(0编辑  收藏  举报