How do you set fade in/out wpf vb.net for images(using xaml code and vbcode) and add it to winforms as usercontrol

StackOverflow https://stackoverflow.com/questions/14552365

Question

How do you set fade in/out wpf vb.net for images(using xaml code and vbcode) and add it to winforms as usercontrol is it possible

i know how to do that with a rectangle in xaml but i want to add the same settings to the existing image box


i used this code for the rectangle


<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>


Thanks in advance

~kirubel Daniel

Was it helpful?

Solution

Do it like this:

<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> 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top