【发布时间】:2014-02-13 02:26:50
【问题描述】:
我正在尝试将 Rectangle 形状的 Opacity 属性绑定到 Slider 的值。因此,当它的值超过 2 时,矩形 淡出,当我们减小滑块的值并且它超过 2 的值时,它会再次出现,并带有 动画淡入。这样做的最佳做法是什么?
<Window x:Class="Layout.AnimateOpacity"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="AnimateOpacity" Height="300" Width="300">
<DockPanel VerticalAlignment="Center" HorizontalAlignment="Center"
Height="300" Width="300">
<Canvas DockPanel.Dock="Top"
Width="300" Height="200"
Background="Black">
<Rectangle x:Name="myRectangle"
Width="100" Height="100"
Canvas.Left="100" Canvas.Top="60"
Fill="Yellow">
</Rectangle>
</Canvas>
<Slider x:Name="mySlider" DockPanel.Dock="Bottom"
Height="30" Width="250"
Value="1" Maximum="3" Minimum="0" />
</DockPanel>
</Window>
【问题讨论】:
标签: wpf xaml triggers fadein fadeout