zoukankan      html  css  js  c++  java
  • WPF获取控件内部的ScrollViewer,并控制ScrollViewer操作

    //获取内部  ScrollViewer方法

    public static T FindVisualChild<T>(DependencyObject obj) where T : DependencyObject
            {
                if (obj != null)
                {
                    for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
                    {
                        DependencyObject child = VisualTreeHelper.GetChild(obj, i);
                        if (child != null && child is T)
                        {
                            return (T)child;
                        }
                        T childItem = FindVisualChild<T>(child);
                        if (childItem != null) return childItem;
                    }
                }
                return null;
            }

     

     

     

     

     

      //通过鼠标滑轮事件控制ScrollViewer滚动

      private void list_MouseWheel(object sender, MouseWheelEventArgs e)
            {
                ItemsControl items = (ItemsControl)sender;
                ScrollViewer scroll = FindVisualChild<ScrollViewer>(items);
                if (scroll != null)
                {
                    int d = e.Delta;
                    if (d > 0)
                    {
                        scroll.LineRight();
                    }
                    if (d < 0)
                    {
                        scroll.LineLeft();
                    }
                    scroll.ScrollToTop();
                }
            }

  • 相关阅读:
    (3)梯度下降法Gradient Descent
    特征工程
    python小笔记
    衡量线性回归法的指标MSE, RMSE,MAE和R Square
    最小二乘法
    最优化原理,凸优化
    线性回归Linear regression
    机器学习流程
    数据归一化Feature Scaling
    kafka重新设置group的offset
  • 原文地址:https://www.cnblogs.com/chuhaida/p/3724776.html
Copyright © 2011-2022 走看看