如何在WPF中容纳GroupBox?

时间:2016-05-25 16:54:52

标签: c# .net wpf mahapps.metro

我有一个" GroupBox"哪个最大化窗口我屈服于其他人" GroupBox"

无法修复它。任何人? Form

这是XAML。这是xml不知道是否有办法添加一些定义来修复,任何标签或东西。

<UserControl x:Class="Laboratorio.Calibracion"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         mc:Ignorable="d" 
         d:DesignHeight="490" d:DesignWidth="660">
<Grid>
    <GroupBox Header="Calibracion" Margin="0,0,0,10">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <GroupBox Grid.Row="0" Grid.Column="0" Header="Equipo">
                <Grid>
                    <Label x:Name="serialLbl" Content="Serial:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0"/>
                    <TextBox x:Name="serialTxb" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Margin="85,10,0,0"/>
                    <TextBox x:Name="descripcionTxb" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="144" Margin="209,10,0,0" IsEnabled="False"/>
                    <Label x:Name="resolucionLbl" Content="Resolucion:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,41,0,0"/>
                    <TextBox x:Name="resolucionTxb" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Margin="85,41,0,0"/>
                </Grid>
            </GroupBox>
            <GroupBox Grid.Row="0" Grid.Column="1" Header="Patron">
                <Grid>
                    <Label x:Name="patronLbl" Content="Patron:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0"/>
                    <ComboBox x:Name="comboBox" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" Margin="106,10,0,0"/>
                    <Label x:Name="patronLbl_Copy" Content="Niv. Referencia:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,80,0,0"/>
                    <TextBox x:Name="resolucionTxb_Copy" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Margin="106,80,0,0"/>
                    <Label x:Name="patronLbl_Copy1" Content="Fluido:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,41,0,0"/>
                    <ComboBox x:Name="comboBox_Copy" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" Margin="106,41,0,0"/>
                </Grid>
            </GroupBox>
            <GroupBox Grid.Row="1" Grid.Column="0" Header="Condificones">
                <Grid>
                    <Label x:Name="temperaturaLbl" Content="Temperatura:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0"/>
                    <TextBox x:Name="temperaturaTxb" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="36" Margin="94,10,0,0"/>
                    <Label x:Name="humedadLbl" Content="Humedad:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="135,10,0,0"/>
                    <TextBox x:Name="humedadTxb" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="35" Margin="205,10,0,0"/>
                </Grid>
            </GroupBox>
            <GroupBox Grid.Row="2" Grid.Column="0" Header="Comprobacion Inicial">
                <Grid>
                    <DataGrid x:Name="compInicialDgv">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Presion Patron"></DataGridTextColumn>
                            <DataGridTextColumn Header="Lecturas"></DataGridTextColumn>
                            <DataGridTextColumn Header="Error"></DataGridTextColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </GroupBox>
            <GroupBox Grid.Row="2" Grid.Column="1" Header="Segunda Secuencia">
                <Grid>
                    <DataGrid x:Name="segSecDgv">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Presion Patron"></DataGridTextColumn>
                            <DataGridTextColumn Header="Lecturas"></DataGridTextColumn>
                            <DataGridTextColumn Header="Error"></DataGridTextColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </GroupBox>
        </Grid>
    </GroupBox>
</Grid>

1 个答案:

答案 0 :(得分:1)

您使用的是硬编码尺寸属性(Raw Formatting:24 On-disk formatting:0.1 Slack space:0.3 Select protection; 1=FTT, 2=EC-1, 3=EC-2:1 Traceback (most recent call last): File "C:\Users\Ed\Desktop\hello.py", line 7, in <module> answer = raw * (1-disk) * (1-slack) * 0.5 TypeError: unsupported operand type(s) for -: 'int' and 'str' MarginWidth等)。我假设您是通过工具箱中的拖放设计的。使用此类硬编码值调整表单大小时,您可能会得到奇怪的结果。

我建议您更改所有这些内容以摆脱硬编码边距,编辑父Height以使用GridRowDefinitions以及相应的大小调整信息(绝对值,自动,* ),设置ColumnDefinitions控件的Grid.Row Grid.Column Grid.ColumnSpanGrid.RowSpan属性,然后调整各种大小调整详细信息(GroupBox,{ <1}},MarginPadding等,视需要而定。

对任何子MinWidth元素执行相同的操作。您可能还想使用其他容器元素。

这是我正在谈论的一个简洁的例子。

MinHeight