示例#1
0
        public void Attach(DependencyObject associatedObject)
        {
            AssociatedObject = associatedObject;

            // process start
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                element.Visibility = Visibility.Visible;
            }
            else
            {
                _dispatcher = Common.DispatcherWrapper.Current();

                // throttled calculate event
                _throttleHelper = new EventThrottleHelper();
                _throttleHelper.ThrottledEvent += delegate { Calculate(); };
                _throttleHelper.Throttle = 1000;

                // handle click
                element.Click += new Common.WeakReference<NavButtonBehavior, object, RoutedEventArgs>(this)
                {
                    EventAction = (i, s, e) => Element_Click(s, e),
                    DetachAction = (i, w) => element.Click -= w.Handler,
                }.Handler;
                CalculateThrottled();
            }
        }
示例#2
0
 public NavButtonBehavior()
 {
     if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled)
     {
         _dispatcher = Common.DispatcherWrapper.Current();
         _throttleHelper = new EventThrottleHelper { Throttle = 1000 };
     }
 }
示例#3
0
 public void Detach()
 {
     _throttleHelper = null;
     if (Frame != null)
     {
         Frame.SizeChanged -= SizeChanged;
         Frame.LayoutUpdated -= LayoutUpdated;
     }
     UnregisterPropertyChangedCallback(Frame.CanGoBackProperty, _goBackReg);
     UnregisterPropertyChangedCallback(Frame.CanGoForwardProperty, _goForwardReg);
 }
示例#4
0
 public NavButtonBehavior()
 {
     _dispatcher = Common.DispatcherWrapper.Current();
     _throttleHelper = new EventThrottleHelper { Throttle = 1000 };
 }
 public ThrottledEventTriggerBehavior()
 {
     throttleHelper = new EventThrottleHelper();
     throttleHelper.ThrottledEvent += ThrottleHelperOnThrottledEvent;
 }