Note that there are some explanatory texts on larger screens.

plurals
  1. POFade transition between styles
    primarykey
    data
    text
    <p>I have a label control where I use a converter to switch its styles based on a bool property, IsCheckedOut on my viewmodel, like so:</p> <pre><code> &lt;UserControl.Resources&gt; &lt;Converters:BooleanStyleConverter x:Key="BooleanStyleConverter " StyleFalse="{StaticResource HeaderLabelStyle}" StyleTrue="{StaticResource HeaderLabelHighlightedStyle}" /&gt; &lt;/UserControl.Resources&gt; &lt;Label Style="{Binding Path=IsCheckedOut, Converter={StaticResource BooleanStyleConverter}}"&gt; some content here &lt;/Label&gt; </code></pre> <p>The converter simply returns one of the two styles:</p> <pre><code>public class BooleanStyleConverter : IValueConverter { public Style StyleFalse { get; set; } public Style StyleTrue { get; set; } public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if ((bool)value) { return StyleTrue; } return StyleFalse; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } </code></pre> <p>And the styles look something like this:</p> <pre><code>&lt;Style x:Key="HeaderLabelHighlightedStyle" TargetType="{x:Type Label}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="Label"&gt; &lt;Border Background="{StaticResource RedGradient}"&gt; &lt;ContentPresenter /&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;Style x:Key="HeaderLabelHighlightedStyle" TargetType="{x:Type Label}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="Label"&gt; &lt;Border Background="{StaticResource BlueGradient}"&gt; &lt;ContentPresenter /&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>So when IsCheckedOut is true the label gets a red background, and when it's false it gets a blue background (well, the styles are a bit more complicated, but you get the idea). Now, I'd like to have a transition between the styles, so that the new colors fade in when IsCheckedOut changes. Does anyone know how I can accomplish this? </p>
    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