Note that there are some explanatory texts on larger screens.

plurals
  1. POXAML Storyboard for Background ImageBrush
    text
    copied!<p>I have the following XAML Grid:</p> <pre><code> &lt;Grid Style="{StaticResource LayoutRootStyle}" x:Name="mainGrid"&gt; &lt;Grid.Resources&gt; &lt;Storyboard x:Name="FadeOut"&gt; &lt;DoubleAnimation Duration="3" To="0.0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="gridBackgroundImageBrush" d:IsOptimized="True"/&gt; &lt;/Storyboard&gt; &lt;Storyboard x:Name="FadeIn"&gt; &lt;DoubleAnimation Duration="3" To="0.35" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="gridBackgroundImageBrush" d:IsOptimized="True"/&gt; &lt;/Storyboard&gt; &lt;/Grid.Resources&gt; &lt;Grid.Background&gt; &lt;ImageBrush x:Name="gridBackgroundImageBrush" ImageSource="{Binding BackgroundImage}" Opacity="0.35"&gt; &lt;/ImageBrush&gt; &lt;/Grid.Background&gt; </code></pre> <p>I want to programmatically start the "FadeOut" animation and change the Image from ImageBrush, then start the "FadeIn" animation, like this:</p> <pre><code>private void t_Tick(object sender, object e) { try { FadeOut.Begin(); this.DefaultViewModel["BackgroundImage"] = BackgroundImage; FadeIn.Begin(); } catch { } } </code></pre> <p>However the image is changing without any animation. I guess the problem is about how I'm accessing the "Opacity" property of the ImageBrush. I tried the following syntax for the TargetProperty attribute:</p> <pre><code>(Control.Background).(ImageBrush.Opacity) </code></pre> <p>as msdn shows here: <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.media.animation.storyboard.settargetproperty.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.media.animation.storyboard.settargetproperty.aspx</a> but it doesn't seem to work. Can someone help me with this problem?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload