【问题标题】:Placing more than one element into a GroupBox in WPF在 WPF 中将多个元素放入 GroupBox
【发布时间】:2013-11-17 05:50:55
【问题描述】:

我正在尝试制作一个带有几个(单选)按钮的 GroupBox。但在示例中我使用的是复选框。

<GroupBox Header="Aðgerðir" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="270,0,0,178" Height="106" Width="176">
    <CheckBox Content="CheckBox" HorizontalAlignment="Left" VerticalAlignment="Top"/>
    <CheckBox Content="CheckBox" HorizontalAlignment="Left" VerticalAlignment="Bottom"/>
</GroupBox>

上述方法不起作用,Visual Studio 显示“无效标记”。

这里可以正常工作

<GroupBox Header="Aðgerðir" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="270,0,0,178" Height="106" Width="176">
    <CheckBox Content="CheckBox" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</GroupBox>

我不明白。如果我运行调试器,它会说“内容只能设置一次”,但删除复选框的内容部分似乎没有效果。

【问题讨论】:

    标签: c# wpf radio-button groupbox


    【解决方案1】:

    GroupBox 的内容只能设置一次,这意味着它里面只能有一个控件。如果您想要两个单选按钮,请将它们放在堆栈面板或网格中。

    GroupBox Overview

    <GroupBox Header="Aðgerðir" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="270,0,0,178" Height="106" Width="176">
        <StackPanel>
            <CheckBox Content="CheckBox" HorizontalAlignment="Left" VerticalAlignment="Top"/>
            <CheckBox Content="CheckBox" HorizontalAlignment="Left" VerticalAlignment="Bottom"/>
        </StackPanel>    
    </GroupBox>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-16
      • 1970-01-01
      • 2017-11-30
      • 2017-10-25
      • 2018-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多