Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Buttons > Data-binding a collection of radio buttons

Not answered Data-binding a collection of radio buttons

Feed from this thread
  • Richard avatar

    Posted on Sep 23, 2011 (permalink)

    Hi,


    Is it possible to bind a collection of RadRadioButton to a view model property? I'd like to avoid hard-coding the different options in the XAML.

    I tried the following - it generates a button for each item, but the buttons are grayed out and cannot be selected:

    <ItemsControl ItemsSource="{Binding AllOrderTypes}" >
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate>
               <telerik:RadRadioButton GroupName="OrderType" Content="{Binding}" Click="OrderTypeButtonClick" />                                                   
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>

    Is there a better way?


    Thanks for your help,
    Richard

    Reply

  • Petar Mladenov Petar Mladenov admin's avatar

    Posted on Sep 28, 2011 (permalink)

    Hi Richard,

     I modified your solution a so that the RadioButtons' Content property is properly bound to a ViewModel's string property. Please examine it and let me know if the suggested approach satisfies you.

    Greetings,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Attached files

    Reply

  • Richard avatar

    Posted on Sep 28, 2011 (permalink)

    Hi Petar,

    Thank you! I'll try this out and let you know if I run into any issues.

    Thanks,
    Richard

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Buttons > Data-binding a collection of radio buttons