The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
How to have 2 radio buttons on the same line? RRS feed

  • Question

  • Hi,

    I have not been able to locate a solution to my question for the WP7 platform.  Found lots of PHP etc but need an answer for a WP7 app...

    I have a setting page that I am asking the user to define a "Type" as type 1 or type 2 using radion buttons (Vessel Type, Sail or Power) but I am running out of realestate on the page and need to have these options (radio buttons) side by side on the same line.  It always defaults to over and under.

    So far I have...
                    <StackPanel Height="164" Name="stackPanel2" Width="417">  
                        <TextBlock Height="30" Name="textBlock5" Text="Vessel Type..." /> 
                        <RadioButton Content="Power" Height="71" Name="rbPower" GroupName="VesselType" /> 
                        <RadioButton Content="Sail" Height="71" Name="rbSail" GroupName="VesselType" /> 
                    </StackPanel> 
     

    As yet I have not defined a CSS file for anything particular.

    What is the best solution for my issue?

    Thanks
    Phill
    Thursday, July 12, 2012 4:20 PM

Answers

  • Set the StackPanel's orientation property to Horizontal.
    Thursday, July 12, 2012 4:50 PM
  • StackPanel's default Orientation is "Vertical". That's why Jim suggested you to set it to "Horizontal".

    But in your case you also have a TextBlock. So if you set current StackPanel.Orientation="Horizonta", then all 3 controls will be put side by side and it may go off the screen.

    So you can enclose only the two RadioButtons in a separate StackPanel with Orientation="Horizontal".
    Thursday, July 12, 2012 4:59 PM

All replies

  • Set the StackPanel's orientation property to Horizontal.
    Thursday, July 12, 2012 4:50 PM
  • StackPanel's default Orientation is "Vertical". That's why Jim suggested you to set it to "Horizontal".

    But in your case you also have a TextBlock. So if you set current StackPanel.Orientation="Horizonta", then all 3 controls will be put side by side and it may go off the screen.

    So you can enclose only the two RadioButtons in a separate StackPanel with Orientation="Horizontal".
    Thursday, July 12, 2012 4:59 PM
  • Hi,

    Thanks that did the trick...

    Thanks
    Phill
    Thursday, July 12, 2012 10:10 PM