Welcome to our Microsoft Q&A platform!
Would you like to use Canvas instead of Image?see my test code,it works well.
<Window.Resources>
<Storyboard x:Key="Storyboard_for_Wave" x:Name="Storyboard_for_Wave">
<!-- Completed="Storyboard_for_Wave_Completed" -->
<!-- RepeatBehavior="5x" -->
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Duration="0:0:1.2" Storyboard.TargetName="canvas1" >
<DiscreteObjectKeyFrame KeyTime="0:0:0">
<DiscreteObjectKeyFrame.Value>
<ImageBrush ImageSource="pack://application:,,,/Test;component/Images/1.jpg"/>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame KeyTime="0:0:.3">
<DiscreteObjectKeyFrame.Value>
<ImageBrush ImageSource="pack://application:,,,/Test;component/Images/2.jpg"/>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame KeyTime="0:0:.6">
<DiscreteObjectKeyFrame.Value>
<ImageBrush ImageSource="pack://application:,,,/Test;component/Images/3.jpg"/>>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame KeyTime="0:0:.9">
<DiscreteObjectKeyFrame.Value>
<ImageBrush ImageSource="pack://application:,,,/Test;component/Images/4.jpg"/>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<StackPanel>
<Button Content="btn1">
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click" >
<BeginStoryboard Storyboard="{StaticResource Storyboard_for_Wave}" ></BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
<!--<Image x:Name="image1"></Image>-->
<Canvas x:Name="canvas1" Width="200" Height="200"></Canvas>
</StackPanel>
Thanks.
Hi, please tell us, which property of which UI-Control you want to use for animating with StoryBoard, e.g. where you want assign Canvas. Please, show XAML without StoryBoard, only UI-Element with Property and included Canvas.
anonymous user-3316
I can't enter entire code due to 1000 characters limitation here.
Well. Very simplified.
Within a common Canvas:
The Paths which pose the content are located in a shape which poses the Container.
Scenario: emptying Container. Replacement Canvases one after another.
Thanks.
Btw, working with ImageBrush and BitmapImage had given poor results in tems of image quality.
Hi, is this that what you mean?
Maybe... I didn't try that.
So, how to replace "CanvasFromStoryboard" by means of Storyboard?
I'm asking because as I wrote above a work with Images had given poor results. So I would like to try with Canvases.
thanks.
Hi, I unterstand your question that you have a parent canvas and you want different canvases as children inside the parent canvas. Adding canvases as children via Storyboard is impossible in XAML in DiscreteObjectKeyFrame.Value because Storyboard work in other thread and instantiate new canvases in this other thread. You must at first instantiate canvas in UI thread and then use these instances in Storyboard. Now I haven't any solution for this case.
Please, write at first which target you want use in Storryboard.
What is your storyboard.TargetName?if targetname is image,you can't set Canvas as DiscreteObjectKeyFrame.Value.
Sign in to comment