WPF中GroupBox只能包含一个元素的问题(Error XLS0501 The property ‘Content‘ is set more than once)

Yes, in WPF the GroupBox will contain maximum of 1 element. You can include Grid as its child and in grid specify your desired components. For example 1 placed two buttons in GroupBox using Grid.

GroupBox
            Header="Read Sensor"
            HorizontalAlignment="Left"
            Margin="485,4,0,0"
            VerticalAlignment="Top"
            Height="188"
            Width="238">
            <Grid
                HorizontalAlignment="Left"
                Height="169"
                Margin="0,0,-13,-3"
                VerticalAlignment="Top"
                Width="229">
                <Button
                    x:Name="btnReadSensor1"
                    Content="Read Sensor 1"
                    HorizontalAlignment="Left"
                    Margin="10,91,0,0"
                    VerticalAlignment="Top"
                    Width="207"
                    Click="btnReadSensor1_Click" />
                <Button
                    x:Name="btnReadSensor2"
                    Content="Read Sensor 2"
                    HorizontalAlignment="Left"
                    Margin="10,64,0,0"
                    VerticalAlignment="Top"
                    Width="207"
                    Click="btnReadSensor2_Click" />
            </Grid>
</GroupBox>
上一篇:C#及WPF多线程定义和使用


下一篇:WPF性能优化