小编C. *_*her的帖子

WPF:无法在 DataGrids 中滚动

我有一个管理锦标赛的应用程序。我有滚动问题的视图如下所示:Group Phase View Screenshot

现在我遇到了当鼠标悬停在 DataGrid 上时无法滚动的问题。例如,只要我尝试在扩展器上滚动 - 它就可以工作(但是一旦鼠标再次越过 DataGrid,滚动就会停止)。ScrollViewer 本身也按预期工作,例如当我尝试使用滚动条本身滚动时。

视图构建如下...

我有一个看起来像这样的 GroupPhaseView(这个视图包含 ScrollViewer):

<UserControl x:Class="TournamentApplication.UI.Tournament.GroupPhase.GroupPhaseView"
         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"
         xmlns:groupPhase="clr-namespace:TournamentApplication.UI.Tournament.GroupPhase"
         mc:Ignorable="d" 
         d:DesignHeight="450" d:DesignWidth="800">
<Grid>
    <ScrollViewer VerticalScrollBarVisibility="Auto">
        <ItemsControl ItemsSource="{Binding GroupPhaseCategoryViewModels}">
            <ItemsControl.ItemTemplate>
                <DataTemplate DataType="groupPhase:GroupPhaseCategoryViewModel">
                    <groupPhase:GroupPhaseCategoryView />
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </ScrollViewer>
</Grid>
Run Code Online (Sandbox Code Playgroud)

此 GroupPhaseView 包含多个 GroupPhaseCategoryView。一个 GroupPhaseCategoryView 看起来像这样:

<UserControl x:Class="TournamentApplication.UI.Tournament.GroupPhase.GroupPhaseCategoryView"
         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"
         xmlns:groupPhase="clr-namespace:TournamentApplication.UI.Tournament.GroupPhase"
         mc:Ignorable="d" 
         d:DesignHeight="450" d:DesignWidth="800">
<Grid>
    <Expander Header="{Binding Category.Name}" IsExpanded="True">
        <ItemsControl ItemsSource="{Binding GroupPhaseGroupViewModels}">
            <ItemsControl.ItemTemplate>
                <DataTemplate DataType="groupPhase:GroupPhaseGroupViewModel">
                    <groupPhase:GroupPhaseGroupView />
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </Expander>
</Grid>
Run Code Online (Sandbox Code Playgroud)

此 GroupPhaseCategoryView 包含多个 GroupPhaseGroupView。它们包含两个导致滚动问题的 …

c# wpf datagrid scrollviewer

4
推荐指数
1
解决办法
1520
查看次数

标签 统计

c# ×1

datagrid ×1

scrollviewer ×1

wpf ×1