【问题标题】:Expander scrolling problems扩展器滚动问题
【发布时间】:2019-10-16 18:56:51
【问题描述】:

我在StackpanelScrollViewer 中有一个Expander。 现在,当我将鼠标移到展开的扩展器上时,滚动查看器的滚动不再起作用。 有人可以帮我理解为什么吗?

<ScrollViewer VerticalScrollBarVisibility="Auto" Name="Scroller">
    <StackPanel  Name="Panel1">
            <Expander Header="{Binding Source={x:Static properties:Strings.GeneralSettings}}" IsExpanded="True">
                <StackPanel>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <TextBox Grid.Column="0" Grid.Row="0" Text="{Binding ProjectDataService.CurrentProject.ProjectName,Mode=TwoWay}" material:TextFieldAssist.Hint="Projektname" Margin="10" />
                        <TextBox Grid.Column="1" Grid.Row="0" Text="{Binding ProjectDataService.CurrentProject.ProjectLead,Mode=TwoWay}" material:TextFieldAssist.Hint="Projektleitung" Margin="10" />
                        <TextBox Grid.Column="0" Grid.Row="1" Text="{Binding ProjectDataService.CurrentProject.City,Mode=TwoWay}"  material:TextFieldAssist.Hint="Ort" Margin="10" />
                        <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding ProjectDataService.CurrentProject.ZipCode,Mode=TwoWay}" material:TextFieldAssist.Hint="Postleitzahl" Margin="10" />
                        <TextBox Grid.Column="0" Grid.Row="2" Text="{Binding ProjectDataService.CurrentProject.Street,Mode=TwoWay}" material:TextFieldAssist.Hint="Strasse" Margin="10" />
                        <TextBox Grid.Column="1" Grid.Row="2" Text="{Binding ProjectDataService.CurrentProject.HouseNumber,Mode=TwoWay}" material:TextFieldAssist.Hint="Hausnummer" Margin="10" />
                        <TextBox Grid.Column="0" Grid.Row="3" Text="{Binding ProjectDataService.CurrentProject.ContactName,Mode=TwoWay}" material:TextFieldAssist.Hint="Ansprechpartner vor Ort" Margin="10" />
                        <TextBox Grid.Column="1" Grid.Row="3" Text="{Binding ProjectDataService.CurrentProject.ContactEmail,Mode=TwoWay}" material:TextFieldAssist.Hint="Kontaktemail" Margin="10" />
                        <ComboBox Grid.Column="0" Grid.Row="4" Margin="10" SelectedItem="{Binding ProjectDataService.CurrentProject.ProjectStatus,Mode=TwoWay}" material:TextFieldAssist.Hint="Projektstand">
                            <ComboBoxItem Content="Abgenommen" />
                            <ComboBoxItem Content="Eingebaut" />
                        </ComboBox>
                    </Grid>                        
                </StackPanel>
            </Expander>
    </StackPanel>
</ScrollViewer>

我发现是 MaterialDesign 框架破坏了滚动。要启用我需要放置的框架

<ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>

            <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Indigo.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Indigo.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

进入 application.ressources。

第二行中断滚动

【问题讨论】:

  • 你能提供一些代码吗?
  • 你能发一个Minimal, Complete, and Verifiable example吗?我得到ScrollViewer,将StackPanel 放入其中,然后将Expander 放入其中,最后将大内容放入Expander - 展开和鼠标移动后滚动效果很好。
  • 从提供的示例中删除所有绑定和material:TextFieldAssist.Hint 条目后(以便能够编译它),滚动仍然有效。您能否提供带有代码隐藏(但尽可能少)的完整程序示例,其中滚动也不起作用?
  • 在添加我的代码直到它停止工作后,我发现问题似乎是我正在使用的材料设计框架。当我把它放在我的代码中时,滚动不再起作用了。

标签: wpf scroll material-design expander


【解决方案1】:

我有同样的问题。这是材料设计nuget中的一个错误:https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/issues/1395

在 materialdesignthemes 3.0 的当前预览中已修复。在 nuget 管理器中选中“include prerelease”,以便能够选择此 nuget 包的预览版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-24
    • 2012-10-23
    • 2011-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多