0

您如何为图像设置淡入/淡出 wpf vb.net(使用 xaml 代码和 vbcode)并将其作为用户控件添加到 winforms 是可能的

我知道如何使用 xaml 中的矩形来做到这一点,但我想将相同的设置添加到现有的图像框


我将此代码用于矩形


<Rectangle Name="myrect" Width="350" Height="250">
<Rectangle.Fill>
    <SolidColorBrush x:Name="brush" Color="Red"/>
</Rectangle.Fill>
<Rectangle.Triggers>
    <EventTrigger RoutedEvent="Window.Loaded">
        <BeginStoryboard>
            <Storyboard>
                <DoubleAnimation Storyboard.TargetName="myrect" 
                    Storyboard.TargetProperty="Opacity" From="0" To="1" 
                    Duration="0:0:1" BeginTime="0:0:0" AutoReverse="True" 
                    RepeatBehavior="Forever"/>
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>    
   </Rectangle.Triggers>


提前致谢

~kirubel丹尼尔

4

1 回答 1

1

像这样做:

<Image x:Name="img01" Height="48" VerticalAlignment="Top" Source="Picture.png" Margin="187,25,165,0">
    <Image.Triggers>
        <EventTrigger RoutedEvent="Window.Loaded">
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetName="img01"
                        Storyboard.TargetProperty="Opacity" From="0" To="1" 
                        Duration="0:0:1" BeginTime="0:0:0" AutoReverse="True" 
                        RepeatBehavior="Forever"/>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Image.Triggers>
</Image> 
于 2013-04-10T14:22:34.367 回答