title: How can we display grouped radio buttons horizontally in WPF?
body: <h2>How can we display Vertical radio button in horizontally manner in WPF</h2>
  
  <p>I am working on a WPF project and I am using this code to create a list box radio group which is bind with my Data Srouce.</p>
  
  <p>I have used below code to create a listbox with radio button and bind it with my datasource</p>
  
  <p>Code :</p>
  
  <pre><code>`&lt;Window.Resources&gt;
      &lt;Style x:Key="radioListBox" TargetType="ListBox" BasedOn="{StaticResource {x:Type ListBox}}"&gt;
          &lt;Setter Property="BorderThickness" Value="0" /&gt;
          &lt;Setter Property="Margin" Value="5" /&gt;
          &lt;Setter Property="DisplayMemberPath" Value="Text" /&gt;
          &lt;Setter Property="SelectedValuePath" Value="Value" /&gt;
          &lt;Setter Property="Background" Value="{x:Null}" /&gt;
          &lt;Setter Property="ItemContainerStyle"&gt;
              &lt;Setter.Value&gt;
                  &lt;Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}"&gt;
                      &lt;Setter Property="Template"&gt;
                          &lt;Setter.Value&gt;
                              &lt;ControlTemplate TargetType="ListBoxItem"&gt;
                                  &lt;Grid Background="Transparent"&gt;
                                      &lt;RadioButton Focusable="False"  Margin="5,5,5,5" IsHitTestVisible="False" IsChecked="{TemplateBinding IsSelected}"&gt;
                                          &lt;ContentPresenter /&gt;
                                      &lt;/RadioButton&gt;
                                  &lt;/Grid&gt;
                              &lt;/ControlTemplate&gt;
                          &lt;/Setter.Value&gt;
                      &lt;/Setter&gt;
                  &lt;/Style&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
      &lt;/Window.Resources&gt;
  
  
  
  &lt;DockPanel&gt;
      &lt;!-- StatusBar just to make sure two-way binding is working properly --&gt;
      &lt;StatusBar DockPanel.Dock="Bottom" BorderBrush="Black" BorderThickness="0,1,0,0"&gt;
          &lt;TextBlock Text="{Binding CurrentChild.Details}" TextWrapping="Wrap" /&gt;
      &lt;/StatusBar&gt;
  
      &lt;!-- Details pane --&gt;
      &lt;Border Margin="5" BorderBrush="LightGray" BorderThickness="1"&gt;
          &lt;Grid&gt;
              &lt;Grid.Resources&gt;
                  &lt;!-- Common style for header labels --&gt;
                  &lt;Style TargetType="Label"&gt;
                      &lt;Setter Property="HorizontalAlignment" Value="Right" /&gt;
                      &lt;Setter Property="VerticalAlignment" Value="Top" /&gt;
                      &lt;Setter Property="FontWeight" Value="Bold" /&gt;
                      &lt;Setter Property="Margin" Value="5,2" /&gt;
                  &lt;/Style&gt;
              &lt;/Grid.Resources&gt;
  
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="Auto" MinWidth="104" /&gt;
                  &lt;ColumnDefinition /&gt;
              &lt;/Grid.ColumnDefinitions&gt;
  
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition Height="Auto" MinHeight="27" /&gt;
                  &lt;RowDefinition Height="Auto" MinHeight="27" /&gt;
              &lt;/Grid.RowDefinitions&gt;
  
  
              &lt;Label Grid.Row="3" Content="My Sample Numbers:" /&gt;
  
              &lt;ListBox Grid.Row="3" Grid.Column="1" Style="{StaticResource radioListBox}" 
                       ItemsSource="{Binding MyNumberTypes}" Height="Auto" Margin="5,4,5,0" VerticalAlignment="Top" /&gt;
          &lt;/Grid&gt;
      &lt;/Border&gt;
  &lt;/DockPanel&gt;`
  
  
  
      public IEnumerable&lt;ValueAndText&lt;NumType&gt;&gt; MyNumberTypes
          {
              get
              {
                  yield return new ValueAndText&lt;NumType&gt;(NumType.One, "One");
                  yield return new ValueAndText&lt;NumType&gt;(NumType.Two, "Two");
                  yield return new ValueAndText&lt;NumType&gt;(NumType.Three, "Three");
                  yield return new ValueAndText&lt;NumType&gt;(NumType.Four, "Four");
                  yield return new ValueAndText&lt;NumType&gt;(NumType.Five, "Five");
                  yield return new ValueAndText&lt;NumType&gt;(NumType.Six, "Six");
                  yield return new ValueAndText&lt;NumType&gt;(NumType.Seven, "Seven");
                  yield return new ValueAndText&lt;NumType&gt;(NumType.Eight, "Eight");
                  yield return new ValueAndText&lt;NumType&gt;(NumType.Nine, "Nine");
              }
          }`
  </code></pre>
  
  <p>Every thing is working fine but the problem is I need all radio button to display in zig zag style. Since my form does not have much space to accommodate the radio buttons vertically so is there any way I can display these radio button in a way it can be displayed horizontally? </p>
  
  <p>for example (cant post image)</p>
  
  <pre><code>One   Two   Three
  Four  Five  Six
  Seven Eight Nine
  </code></pre>