• 回到顶部按钮


     void MainPage_Loaded(object sender, RoutedEventArgs e)
            {
    
    
                #region 回到顶部按钮
    
                // Visual States are always on the first child of the control template
                FrameworkElement element = VisualTreeHelper.GetChild(viewer_hot, 0) as FrameworkElement;
                if (element != null)
                {
                    VisualStateGroup group = FindVisualState(element, "ScrollStates");
                    if (group != null)
                    {
                        //group.CurrentStateChanging += (s, args) => pivot.Title = args.NewState.Name;
                        group.CurrentStateChanging += (s, args) =>
                        {
                            if (args.NewState.Name == "Scrolling")
                            {
                                imgTopBack.Visibility = System.Windows.Visibility.Collapsed;
                            }
                            else if (viewer_hot.VerticalOffset > 1)
                            {
                                imgTopBack.Visibility = System.Windows.Visibility.Visible;
                            }
                        };
                    }
                }
    
                #endregion
    }
      VisualStateGroup FindVisualState(FrameworkElement element, string name)
            {
                if (element == null) return null;
                IList groups = VisualStateManager.GetVisualStateGroups(element);
                foreach (VisualStateGroup group in groups)
                    if (group.Name == name) return group;
                return null;
            }
     private void imgTopBack_Tap(object sender, System.Windows.Input.GestureEventArgs e)
            {
                viewer_hot.ScrollToVerticalOffset(0.0);
                imgTopBack.Visibility = Visibility.Collapsed;
    
                e.Handled = true;
            }

    xaml 中:

     <Image Height="56" Width="56" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="12,0,0,80" Name="imgTopBack" Source="/images/topBack.png" Stretch="Fill" Visibility="Collapsed" Tap="imgTopBack_Tap" />
  • 相关阅读:
    即时通讯之环信视频语音实时通话与单聊和群聊实现
    检测.net framework 版本
    Abp(.NetCore)开发与发布过程3-部署Ubuntu站点
    Abp(.NetCore)开发与发布过程2
    Abp(.NetCore)开发与发布过程
    Redis实战与 Session缓存
    Redis 安装与初体验
    [转]gluPerspective函数
    [转]gluLookAt 函数详解
    [转]unity3D游戏开发之GUI
  • 原文地址:https://www.cnblogs.com/hebeiDGL/p/2475575.html
Copyright © 2020-2023  润新知