wpf如何实现radiobutton同一排显示

沧海1梦 2017-09-01 04:24:25
请问下如何实现下面的效果,

我加了一个border,然后在里面添加radiobutton,发现实现不了
代码如下:

<Border Grid.Row="0" Margin="20,47,15,497" BorderBrush="#188AE5" BorderThickness="1">
<StackPanel Name="check" Grid.Column="1" Grid.Row="0" Margin="0,10,15,210" Grid.ColumnSpan="2">
<TextBlock Text="区域显示:" Margin="10,0,1067,0" Foreground="Blue" Height="20" />
<RadioButton x:Name="putong" HorizontalAlignment="Left" Height="20" Width="120" IsChecked="True" FlowDirection="RightToLeft" Template="{StaticResource radioBoxTemp}" Checked="putong_Checked" Unchecked="putong_Unchecked" Content="普通" Foreground="White" />
<RadioButton x:Name="zhongdian" HorizontalAlignment="Left" Margin="0 0 10 0" Height="20" Width="60" FlowDirection="RightToLeft" Template="{StaticResource radioBoxTemp}" Checked="zhongdian_Checked" Unchecked="zhongdian_Unchecked" Content="重点" />
<RadioButton x:Name="pingbi" HorizontalAlignment="Left" Margin="0,0,10,0" Height="20" Width="60" IsChecked="True" FlowDirection="RightToLeft" Template="{StaticResource radioBoxTemp}" Checked="pingbi_Checked" Unchecked="pingbi_Unchecked" Content="屏蔽" />
<TextBlock Text="跟踪模式:" Margin="10,0,10,0" Foreground="Blue" Height="20" />
<RadioButton x:Name="shoudong" Margin="0,0,10,0" HorizontalAlignment="Left" Height="20" Width="60" IsChecked="True" FlowDirection="RightToLeft" Template="{StaticResource radioBoxTemp}" Checked="shoudong_Checked" Unchecked="shoudong_Unchecked" Content="手动" />
<RadioButton x:Name="Auto" HorizontalAlignment="Left" Margin="0,0,10,0" Height="20" Width="60" FlowDirection="RightToLeft" Template="{StaticResource radioBoxTemp}" Checked="Auto_Checked" Unchecked="Auto_Unchecked" Content="自动" />
<TextBlock Text="轨迹显示" Margin="15,0,10,0" Foreground="Blue" Height="20"/>
<RadioButton x:Name="display" Margin="0,0,10,0" HorizontalAlignment="Left" Height="20" Width="60" IsChecked="True" FlowDirection="RightToLeft" Template="{StaticResource radioBoxTemp}" Checked="display_Checked" Unchecked="display_Unchecked" Content="显示" />
<RadioButton x:Name="hidden" HorizontalAlignment="Left" Margin="0 0 10 0" Height="20" Width="60" FlowDirection="RightToLeft" Template="{StaticResource radioBoxTemp}" Checked="hidden_Checked" Unchecked="hidden_Unchecked" Content="隐藏" />
</StackPanel>
</Border>
...全文
817 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复 1
用WrapPanel水平布局,而不是垂直布局StackPanel.
当然也可以设置StackPanel的Orientation='Horizontal'实现水平排列。
darthpanda 2017-09-02
  • 打赏
  • 举报
回复
直接看代码脑补不太出来,但是如果只是追求水平对齐,用 VerticalAlignment 和 padding margin 实现不了么

8,756

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧