Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight 2 dynamic data binding Converter
    primarykey
    data
    text
    <p>In Silverlight 2....</p> <p>I have a RadioButton in my xaml code as follows:</p> <pre><code>&lt;RadioButton GroupName="Gender" Content="Male" IsChecked="{Binding Path=Gender, ConverterParameter=1, Mode=TwoWay, Converter={StaticResource RadioStringConverter}}" Width="49" HorizontalAlignment="Left"/&gt; </code></pre> <p>This works great. My issue is in trying to duplicate this functionallity dynamically.</p> <pre><code>RadioButton rb = new RadioButton() {GroupName = "Gender", Content = "Male" ,Width = (double)49,HorizontalAlignment = System.Windows.HorizontalAlignment.Left}; </code></pre> <p>this works but when I try to put the converter in, it breaks. What is the proper way to do this? Any good working examples?</p> <p>Here is what I tried....</p> <pre><code>RadioButton rb = new RadioButton() {GroupName = "Gender", Content = "Male" ,Width = (double)49,HorizontalAlignment = System.Windows.HorizontalAlignment.Left}; RadioStringConverter rsc = new RadioStringConverter(); Binding binding = new Binding(layout.FieldName) { Source = mainLayout.DataContext, Mode = BindingMode.TwoWay,ConverterParameter = 1,Converter = rsc}; // to emulate the "{StaticResource RadioStringConverter}"}; rb.SetBinding(RadioButton.IsCheckedProperty, binding); sp.Children.Add(rb); </code></pre> <p>Although this compiles fine, it does not run correctly. 1) How do I reference the static resource dynamically? 2) How do I add this static resource to the XAML dynamically? Right now I have this reference hard coded.</p> <p>Am I making this more difficult than it needs to be?</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.
    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