【问题标题】:Deactivate button inside ScrollViewer when scrolling is activate激活滚动时停用 ScrollViewer 内的按钮
【发布时间】:2014-12-11 12:46:53
【问题描述】:

我的问题如下。当我滚动时,如果我的手指触摸按钮,将调用该命令。如果用户滚动和相反,MVVM 架构的最佳方式是如何停止此操作并停用按钮。

<ScrollViewer  PanningMode="Both" PanningDeceleration="0.001" PanningRatio="2">
        <Grid>
            <ItemsControl  ItemsSource="{Binding ListGstDescriptors}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Vertical"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>

                        <Button  Command="{StaticResource ChangeSavedViewCommand}"
                                CommandParameter="{Binding GstDescriptorAcDescriptor}"/>

                    </DataTemplate>
                </ItemsControl.ItemTemplate>

            </ItemsControl>
        </Grid>
</ScrollViewer>    

【问题讨论】:

    标签: c# wpf xaml scroll touch


    【解决方案1】:

    只需在滚动移动时将 CanExecute 的行为设置为 false This Link 可以帮助您更好地理解命令

    【讨论】:

    • 是的,这是我想要做的,但如何知道我的功能可以执行滚动移动是激活的?在 ScrollViewer 上,当滚动移动时,什么都不会发生。
    • Just Handle ScrollChanged 事件仅在滚动移动时触发,因此您可以在处理程序中设置或直接设置 CanExecute 的布尔字段
    • 可能是我错了,但像这样,我不知道滚动何时完成将 CanExecute 设置为 true。
    猜你喜欢
    • 2011-05-01
    • 2015-10-31
    • 1970-01-01
    • 2020-09-10
    • 2013-03-05
    • 1970-01-01
    • 1970-01-01
    • 2021-01-05
    • 1970-01-01
    相关资源
    最近更新 更多