【问题标题】:ScrollViewer not showing up properly?ScrollViewer 没有正确显示?
【发布时间】:2009-07-20 16:12:21
【问题描述】:

有谁知道我的代码有什么问题:

<Border Background="AliceBlue" BorderThickness="2">
    <Grid Name="MainGrid" Background="DarkGray" >
        <Grid.RowDefinitions>
            <RowDefinition Height="0.02*"/>
            <RowDefinition Height="0.07*"/>
            <RowDefinition Height="0.63*"/>
            <RowDefinition Height="0.05*"/>
            <RowDefinition Height="0.05*"/>
        </Grid.RowDefinitions>   

        [...SNIP...]

           <StackPanel Grid.Row="2">
            <Expander Header="Filteroptionen" Foreground="WhiteSmoke" FontWeight="Bold">
                <Border Margin="18,10,18,10" Name="border1" CornerRadius="10,10,10,10" Background="Gray" >
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <StackPanel Margin="15,5,5,5" Grid.Column="0">
                            <RadioButton FontWeight="Normal" Foreground="White" Height="19" Name="radtest1">test1</RadioButton>
                            <RadioButton FontWeight="Normal" Foreground="White" Height="19" Name="radtest2">test2</RadioButton>
                            <RadioButton FontWeight="Normal" Foreground="White" Height="19" Name="radtest3">test3</RadioButton>
                        </StackPanel>
                            <StackPanel Margin="15,5,5,5" Grid.Column="1">
                                <my:DatePicker HorizontalAlignment="Left" Height="25" Name="datePicker1" Width="115" Text="Von" />
                                <my:DatePicker HorizontalAlignment="Left" Height="25" Name="datePicker2" Width="115" Text="Bis" IsEnabled="True" />
                            </StackPanel>
                            <StackPanel Margin="15,5,5,5" Grid.Column="2">
                                <WrapPanel>
                                    <Label FontWeight="Normal" Foreground="White" >Number</Label>
                                    <TextBox FontWeight="Normal" Width="193"></TextBox>
                                </WrapPanel>
                                <WrapPanel>
                                    <Label FontWeight="Normal" Foreground="White" >Name</Label>
                                    <TextBox FontWeight="Normal" Width="250"></TextBox>
                                </WrapPanel>

                            </StackPanel>

                        </Grid>
                </Border>
            </Expander>
                    <Border Margin="18,10,18,10" CornerRadius="10,10,10,10" Background="Gray" >
                        <my:DataGrid Margin="10,10,10,10" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="auto" ItemsSource="{Binding}" Name="mainDataGrid" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" />
                </Border>
            </StackPanel>

我在此处附上了一张显示问题的图片(我的滚动条没有正确显示,我认为它被网格剪切了):
Picture

非常感谢您的帮助!

干杯

【问题讨论】:

    标签: c# wpf scrollviewer


    【解决方案1】:

    包含面板的高度不受限制。发生的情况是您的包含面板(包含 DataGrid 的 StackPanel)正在增长到所需的大小,因此 DataGrid 认为它不需要滚动。

    尝试在 StackPanel 上设置一个 Height 值(例如窗口的高度,或类似的东西)。然后滚动条应该会出现并开始工作。

    【讨论】:

      【解决方案2】:

      或者,如果您的容器没有固定高度,请在 ScrollViewer 上设置 MaxHeight。

      【讨论】:

        猜你喜欢
        • 2010-12-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-04-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多