我如何在DockPanel中拉伸comboBox

时间:2016-01-18 13:45:17

标签: wpf xaml statusbar dockpanel

我想创建一个带有组合框,进度条和两个按钮的状态栏。在左边,它必须是进度条,在中心组合框中,获得所有可用空间和右边的两个按钮但是我得到的组合框非常少,而且dockpanel没有填充状态栏..

我的Xaml代码

<StatusBar DockPanel.Dock="Bottom" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <DockPanel Width="1004" Height="Auto" LastChildFill="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
            <ProgressBar Name="ExecutionProgress" Height="Auto" Margin="3" MinWidth="200" MaxWidth="400" DockPanel.Dock="Left"></ProgressBar>
            <StackPanel Orientation="Horizontal" Height="Auto" DockPanel.Dock="Right">
                <Button Name="SaveExecutionLog" Width="Auto" Height="Auto" Content="Save Log" Margin="2" Padding="4"></Button>
                <Button Name="ClearExecutionLog" Width="Auto" Height="Auto" Content="Clear Log" Margin="2" Padding="4"></Button>
            </StackPanel>
            <ComboBox Name="ExecutionEvents" Height="Auto" Width="Auto" Margin="3">
                <ComboBoxItem>jfjfjxdfvbdfhfghfghfghfghfghjfg[pjkhlp'fghfg]ophkfg]pkh]pfg]hkfg]pkh]pfghokfg]pkh]-fg</ComboBoxItem>
            </ComboBox>
        </DockPanel>
</StatusBar>

我的错误在哪里?谢谢!

1 个答案:

答案 0 :(得分:0)

我不知道问题出在哪里,但我通过将DockPanel更改为Grid来修复它。这真是一种魔力。