title: How to bind a dynamic value inside a visualstate
body: <p>In a Universal Windows App how to bind a value inside a visual state in XAML. For the sake of easy understanding I removed the other states except checked state under VisualStateGroups in the code below. </p>
  
  <pre><code>  &lt;Page.Resources&gt;
     &lt;converters:UriToImageBrushConverter x:Key="cnvt"/&gt;
      &lt;Style x:Key="RadioButtonStyletest" TargetType="RadioButton"&gt;
          &lt;Setter Property="Background" Value="Transparent"/&gt;
          &lt;Setter Property="Foreground" Value="{ThemeResource RadioButtonContentForegroundThemeBrush}"/&gt;
          &lt;Setter Property="Padding" Value="1,4,0,0"/&gt;
          &lt;Setter Property="HorizontalAlignment" Value="Stretch"/&gt;
          &lt;Setter Property="VerticalAlignment" Value="Center"/&gt;
          &lt;Setter Property="HorizontalContentAlignment" Value="Left"/&gt;
          &lt;Setter Property="VerticalContentAlignment" Value="Top"/&gt;
          &lt;Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/&gt;
          &lt;Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="RadioButton"&gt;
                      &lt;Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"&gt;
                          &lt;VisualStateManager.VisualStateGroups&gt;                               
                              &lt;VisualStateGroup x:Name="CheckStates"&gt;
                                  &lt;VisualState x:Name="Checked"&gt;
                                      &lt;Storyboard&gt;
                                          &lt;DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="CheckGlyph"/&gt;
                                      &lt;/Storyboard&gt;
                                  &lt;/VisualState&gt;
                                  &lt;VisualState x:Name="Unchecked"/&gt;
                                  &lt;VisualState x:Name="Indeterminate"/&gt;
                              &lt;/VisualStateGroup&gt;                             
                          &lt;/VisualStateManager.VisualStateGroups&gt;
                          &lt;Grid&gt;
                              &lt;Grid.ColumnDefinitions&gt;
                                  &lt;ColumnDefinition Width="29"/&gt;
                                  &lt;ColumnDefinition Width="*"/&gt;
                              &lt;/Grid.ColumnDefinitions&gt;
                              &lt;Grid VerticalAlignment="Top"&gt;
                                  &lt;Ellipse x:Name="BackgroundEllipse" Height="23" Fill="{Binding Imgsrc, Converter={StaticResource cnvt}}" Stroke="{ThemeResource RadioButtonBorderThemeBrush}" StrokeThickness="{ThemeResource RadioButtonBorderThemeThickness}" UseLayoutRounding="False" Width="23"&gt;
  
                                  &lt;/Ellipse&gt;
                                  &lt;Ellipse x:Name="CheckGlyph" Fill="{ThemeResource RadioButtonForegroundThemeBrush}" Height="13" Opacity="0" UseLayoutRounding="False" Width="13"/&gt;
                                  &lt;Rectangle x:Name="FocusVisualWhite" Height="29" Opacity="0" StrokeDashOffset="1.5" StrokeEndLineCap="Square" Stroke="{ThemeResource FocusVisualWhiteStrokeThemeBrush}" StrokeDashArray="1,1" Width="29"/&gt;
                                  &lt;Rectangle x:Name="FocusVisualBlack" Height="29" Opacity="0" StrokeDashOffset="0.5" StrokeEndLineCap="Square" Stroke="{ThemeResource FocusVisualBlackStrokeThemeBrush}" StrokeDashArray="1,1" Width="29"/&gt;
                              &lt;/Grid&gt;
                              &lt;ContentPresenter x:Name="ContentPresenter" AutomationProperties.AccessibilityView="Raw" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" Grid.Column="1" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/&gt;
                          &lt;/Grid&gt;
                      &lt;/Border&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  &lt;/Page.Resources&gt;
  </code></pre>
  
  <p>In the above code i tried to bind the BackgroundEllipse backgroud its not happening.</p>
  
  <p>c# code:</p>
  
  <pre><code>private String imgsrc;
  
      public String Imgsrc
      {
          get
          {
              return imgsrc;
          }
          set
          {
              imgsrc = value;
          }
      }
  
      public MainPage()
      {
          this.InitializeComponent();
  
          Imgsrc = "/Assets/yes.png";
  
      }
  </code></pre>
  
  <p>The Converter</p>
  
  <pre><code>class UriToImageBrushConverter : IValueConverter
  {
  
      public object Convert(object value, Type targetType, object parameter, string language)
      {
          try
          {
              return new BitmapImage(new Uri((string)value));
          }
          catch
          {
              return new BitmapImage();
          }
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, string language)
      {
          throw new NotImplementedException();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Please advice me where I went wrong.</p>