WPF Datagrid-不显示任何滚动条 [英] WPF Datagrid - Not showing any Scrollbar

查看:166
本文介绍了WPF Datagrid-不显示任何滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Datagrid在ObservableCollection上具有绑定,并在对EF提取的某些值进行分组后被填充.

My Datagrid has a binding on an ObservableCollection and gets filled after grouping some values fetched by EF.

我的问题是,datagrid-height超出了窗口大小. 有人知道如何解决该问题吗...我差点把自己用谷歌搜索死了..:o

My Problem is, that the datagrid-height grows beyond the window size. Does anyone know how to get that fixed... I almost googled myself to death.. :o

<UserControl x:Class="UltranizerV2.Views.Storage.InventoryList"
             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">
    <Grid>
        <Grid.RowDefinitions>

            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="25"></RowDefinition>
        </Grid.RowDefinitions>


        <DockPanel  Grid.Row="0" >
            <DataGrid ItemsSource="{Binding PresentableInventoryItems}" VerticalAlignment="Stretch" AutoGenerateColumns="False">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Produkttitel" Width="350" Binding="{ Binding ProductTitle}"/>
                <DataGridTextColumn Header="Sku" Width="100" Binding="{ Binding Sku}" />
                <DataGridTextColumn Header="Menge" Width="60"  Binding="{ Binding Quantity}" />
            </DataGrid.Columns>    
            </DataGrid>
        </DockPanel>
        <Label Grid.Row="1">Arsch</Label>
        </Grid>

</UserControl>

推荐答案

总而言之,您的控件看起来不错,这表明问题出在视觉树的上方.它很可能是InventoryList或它的父级之一,处于受控状态,可以为其子级提供无限量的空间来生长,例如StackPanelScrollViewerCanvas.因此,DataGrid可以增长以容纳所有项目,因此看不到滚动条.

To sum up comments your control looks fine which would suggest that the problem is somewhere up the visual tree. Most likely InventoryList, or one of its parents, it's placed in control that gives its children infinite amount of space to grow like StackPanel, ScrollViewer or Canvas. Because of that DataGrid can grow to accommodate all item hence not scroll bar is visible.

删除该控件或将其替换为限制其子控件大小的控件

Remove that control or replace it with one that limits the size of its children

这篇关于WPF Datagrid-不显示任何滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆