VisualStateManager not working when value is passed through a converter for applying a Button Bg
<p>I am applying a button's background color through a converter. At first it is applied properly but after it is hovered or pressed the background color is gone forever and does not come back. </p>

<p><strong>Desired Behavior</strong></p>

<p>Default State</p>

<p><a href="https://i.stack.imgur.com/xDG0u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xDG0u.png" alt="noraml"></a></p>

<p>Hovered</p>

<p><a href="https://i.stack.imgur.com/4LdR8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4LdR8.png" alt="enter image description here"></a></p>

<p>After Hover State</p>

<p><a href="https://i.stack.imgur.com/xDG0u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xDG0u.png" alt="noraml"></a></p>

<p><strong>My Problem</strong></p>

<p>The orange background does not appear again when the hovered state is over</p>

<p><strong>IMPLEMENTATION</strong> </p>

<p>Button Usage</p>

<pre><code>&lt;Button Content="Continue" Style="{StaticResource ButtonAnyColorStyle}"&gt;
    &lt;Button.Background&gt;
        &lt;SolidColorBrush Color="{Binding something, Converter={StaticResource PanelBgColorConverter}, Mode=TwoWay}"  /&gt;
    &lt;/Button.Background&gt;
&lt;/Button&gt;
</code></pre>

<p>Button Style</p>

<pre><code>&lt;Style x:Key="ButtonAnyColorStyle" TargetType="Button"&gt;
    &lt;Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}" /&gt;
    &lt;Setter Property="Template"&gt;
        &lt;Setter.Value&gt;
            &lt;ControlTemplate TargetType="Button"&gt;
                &lt;Grid Background="Transparent"&gt;
                    &lt;VisualStateManager.VisualStateGroups&gt;
                        &lt;VisualStateGroup x:Name="CommonStates"&gt;
                            &lt;VisualState x:Name="Normal"&gt;
                            &lt;/VisualState&gt;
                            &lt;VisualState x:Name="MouseOver"&gt;
                                &lt;Storyboard&gt;
                                    &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
                                                                   Storyboard.TargetName="ContentContainer"&gt;
                                        &lt;DiscreteObjectKeyFrame KeyTime="0"
                                                                Value="{Binding Path=Background, ElementName=ButtonBackground}" /&gt;
                                    &lt;/ObjectAnimationUsingKeyFrames&gt;
                                    &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
                                                                   Storyboard.TargetName="ButtonBackground"&gt;
                                        &lt;DiscreteObjectKeyFrame KeyTime="0"
                                                                Value="{Binding Path=Foreground, ElementName=ContentContainer}" /&gt;
                                    &lt;/ObjectAnimationUsingKeyFrames&gt;
                                    &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush"
                                                                   Storyboard.TargetName="ButtonBackground"&gt;
                                        &lt;DiscreteObjectKeyFrame KeyTime="0"
                                                                Value="{Binding Path=Background, ElementName=ButtonBackground}" /&gt;
                                    &lt;/ObjectAnimationUsingKeyFrames&gt;
                                &lt;/Storyboard&gt;
                            &lt;/VisualState&gt;
                            &lt;VisualState x:Name="Pressed"&gt;
                                &lt;Storyboard&gt;
                                    &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
                                                                   Storyboard.TargetName="ContentContainer"&gt;
                                        &lt;DiscreteObjectKeyFrame KeyTime="0"
                                                                Value="{Binding Path=Background, ElementName=ButtonBackground}" /&gt;
                                    &lt;/ObjectAnimationUsingKeyFrames&gt;
                                    &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
                                                                   Storyboard.TargetName="ButtonBackground"&gt;
                                        &lt;DiscreteObjectKeyFrame KeyTime="0"
                                                                Value="{Binding Path=Foreground, ElementName=ContentContainer}" /&gt;
                                    &lt;/ObjectAnimationUsingKeyFrames&gt;
                                    &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush"
                                                                   Storyboard.TargetName="ButtonBackground"&gt;
                                        &lt;DiscreteObjectKeyFrame KeyTime="0"
                                                                Value="{Binding Path=Background, ElementName=ButtonBackground}" /&gt;
                                    &lt;/ObjectAnimationUsingKeyFrames&gt;
                                &lt;/Storyboard&gt;
                            &lt;/VisualState&gt;
                            &lt;VisualState x:Name="Disabled"&gt;
                                &lt;Storyboard&gt;
                                    &lt;DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
                                                                   Storyboard.TargetName="ButtonBackground"&gt;
                                        &lt;EasingDoubleKeyFrame KeyTime="0"
                                                              Value="0.2" /&gt;
                                    &lt;/DoubleAnimationUsingKeyFrames&gt;
                                &lt;/Storyboard&gt;
                            &lt;/VisualState&gt;
                        &lt;/VisualStateGroup&gt;
                    &lt;/VisualStateManager.VisualStateGroups&gt;
                    &lt;Border x:Name="ButtonBackground"
                            Background="{TemplateBinding Background}"
                            CornerRadius="12"
                            BorderThickness="1"
                            Margin="{StaticResource PhoneTouchTargetOverhang}"&gt;
                        &lt;ContentControl x:Name="ContentContainer"
                                        ContentTemplate="{TemplateBinding ContentTemplate}"
                                        Content="{TemplateBinding Content}"
                                        Foreground="{TemplateBinding Foreground}"
                                        HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                        Padding="{TemplateBinding Padding}"
                                        VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /&gt;
                    &lt;/Border&gt;
                &lt;/Grid&gt;
            &lt;/ControlTemplate&gt;
        &lt;/Setter.Value&gt;
    &lt;/Setter&gt;
&lt;/Style&gt;
</code></pre>

<p>Converter</p>

<pre><code> public class PanelBgColorConverter : IValueConverter
 {
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value is something)
        {
            switch ((something)value)
            {
                case something.AppTheme:
                    return Application.Current.Resources["AppThemeColorOnly"];

                case something.Phone:
                    return Application.Current.Resources["AppGreenColorOnly"];

                case something.Email:
                    return Application.Current.Resources["AppYellowColorOnly"];

                default:
                    return Colors.Transparent;
            }
        }
        else return Colors.Transparent;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}
</code></pre>

<p>Please note that if a color is passed as StaticResource via XAML, the behavior is perfect. The problem lies with converted value </p>