填充数据网格后状态栏消失

时间:2019-02-26 14:21:25

标签: wpf datagrid statusbar hidden status

我有包含datagrid的用户控件。 即使我有足够的边距并且底部有空白空间,只要填充了网格,我的状态栏就会消失。我在做什么错???

<DockPanel VerticalAlignment="Stretch" LastChildFill="False">

    <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="0,0,0,0">


        <controls:ucXXXXSummary  x:Name="ucSummary"  Margin="20,20,20,30" Height="Auto" Width="Auto"/>

     <controls:XXXXUC x:Name="ucXXXX"  Margin="20,20,20,30" Height="Auto" Width="Auto"/>
    </StackPanel>


    <StatusBar DockPanel.Dock="Bottom" Height="25">
        <StatusBarItem>
            <StatusBarItem>
                <TextBlock Name="lblStatus" Text="abc!!!!!!!!!!!"/>
            </StatusBarItem>
        </StatusBarItem>
    </StatusBar>

</DockPanel>

1 个答案:

答案 0 :(得分:1)

不要依靠边距将元素相对于彼此定位。使用适当的Panel,例如Grid

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <controls:ucXXXXSummary  x:Name="ucSummary" Margin="20,20,20,30" />
    <controls:XXXXUC Grid.Row="1" x:Name="ucXXXX"  Margin="20,20,20,30" />
    <StatusBar Grid.Row="2" Height="25">
        <StatusBarItem>
            <StatusBarItem>
                <TextBlock Name="lblStatus" Text="abc!!!!!!!!!!!"/>
            </StatusBarItem>
        </StatusBarItem>
    </StatusBar>
</Grid>

StackPanels在滚动内容方面表现不佳:Horizontal scroll for stackpanel doesn't work