![](https://pic002.cnblogs.com/images/2011/333311/2011123122433188.jpg)
<Window x:Class="myPanel.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Basic Bindings" Height="400" Width="400"
xmlns:p="clr-namespace:myPanel">
<Window.Resources>
<Style x:Key="mystyle" TargetType="Button">
<Style.Triggers>
<Trigger Property="Button.IsMouseOver" Value="True">
<Setter Property="Background" Value="Yellow"/>
</Trigger>
</Style.Triggers>
<Setter Property="Background" Value="Red"/>
</Style>
</Window.Resources>
<StackPanel>
<Slider Height="21" Name="slider1" Minimum="0" Maximum="5" Value="1">
</Slider>
<Slider Height="21" Name="slider2" Minimum="100" Maximum="500"/>
<Rectangle Width="{Binding ElementName=slider1,Path=Value}" Height="{Binding ElementName=slider2,Path=Value}" Stroke="Blue" StrokeThickness="1">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="Red" Offset="0"> </GradientStop>
<GradientStop Color="White" Offset="0.5"></GradientStop>
<GradientStop Color="red" Offset="1"></GradientStop>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Ellipse Width="100" Height="100">
<Ellipse.Fill>
<RadialGradientBrush GradientOrigin="0,0" RadiusX="0.5" RadiusY="0.5">
<GradientStop Color="White" Offset="0"></GradientStop>
<GradientStop Color="yellow" Offset="{Binding ElementName=slider1,Path=Value}"></GradientStop>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Button Style="{StaticResource mystyle}">abcd</Button>
</StackPanel>
</Window>