Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make add a fade-in/fade-out animation based on ViewModel property value?
    primarykey
    data
    text
    <p>I have a <strong>ViewModel</strong> which exposes the string property <strong>PageToolBarVisible</strong> which can be <strong>true</strong> or <strong>false</strong>:</p> <pre><code>private string _pageToolBarVisible; public string PageToolBarVisible { get { return _pageToolBarVisible; } set { _pageToolBarVisible = value; OnPropertyChanged("PageToolBarVisible"); } } </code></pre> <p>Then on my <strong>View</strong> I have this <strong>DataTrigger</strong> which <strong>displays</strong> or <strong>hides</strong> the toolbar accordingly:</p> <pre><code>&lt;Style x:Key="PageToolBarStyle" TargetType="Border"&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding PageToolBarVisible}" Value="false"&gt; &lt;Setter Property="Visibility" Value="Collapsed"/&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;Border Style="{StaticResource PageToolBarStyle}" DockPanel.Dock="Bottom" Padding="5 5 5 0" Background="#eee"&gt; &lt;Grid Background="#eee"&gt; ... &lt;/Grid&gt; &lt;/Border&gt; </code></pre> <p>How do I now <strong>add an</strong> <strong>animation</strong> so that:</p> <ul> <li>when the ViewModel Property is changed from <strong>true to false</strong>, the <strong>toolbar fades out</strong></li> <li>when the ViewModel Property is changed from <strong>false to true</strong>, the <strong>toolbar fades in</strong></li> </ul> <p>I assume I have to add something like this to my style, but I don't know how or where:</p> <pre><code>&lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetName="PageToolBar" Storyboard.TargetProperty="(TextBlock.Opacity)" From="0.0" To="1.0" Duration="0:0:3"/&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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