public void Attach(DependencyObject associatedObject)
 {
     AssociatedObject = associatedObject;
     _deviceUtils = Utils.DeviceUtils.Current();
     if (_deviceUtils != null) _deviceUtils.Changed += DeviceDispositionBehavior_Changed;
     Update();
     _ready = true;
 }
Exemple #2
0
 public static DeviceUtils Current(Common.WindowWrapper windowWrapper = null)
 {
     windowWrapper = windowWrapper ?? Common.WindowWrapper.Current();
     if (!Cache.ContainsKey(windowWrapper))
     {
         var item = new DeviceUtils(windowWrapper);
         Cache.Add(windowWrapper, item);
         windowWrapper.ApplicationView().Consolidated += new Common.WeakReference <DeviceUtils, ApplicationView, object>(item)
         {
             EventAction  = (i, s, e) => Cache.Remove(windowWrapper),
             DetachAction = (i, w) => windowWrapper.ApplicationView().Consolidated -= w.Handler
         }.Handler;
     }
     return(Cache[windowWrapper]);
 }
 public static DeviceUtils Current(Common.WindowWrapper windowWrapper = null)
 {
     windowWrapper = windowWrapper ?? Common.WindowWrapper.Current();
     if (!Cache.ContainsKey(windowWrapper))
     {
         var item = new DeviceUtils(windowWrapper);
         Cache.Add(windowWrapper, item);
         windowWrapper.ApplicationView().Consolidated += new Common.WeakReference<DeviceUtils, ApplicationView, object>(item)
         {
             EventAction = (i, s, e) => Cache.Remove(windowWrapper),
             DetachAction = (i, w) => windowWrapper.ApplicationView().Consolidated -= w.Handler
         }.Handler;
     }
     return Cache[windowWrapper];
 }
        public void Attach(DependencyObject associatedObject)
        {
            AssociatedObject = associatedObject;
            _throttleHelper.ThrottledEvent += ThrottleHelperOnThrottledEvent;

            // process start
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                element.Visibility = Visibility.Visible;
            }
            else
            {
                // handle click
                element.Click += new Common.WeakReference<NavButtonBehavior, object, RoutedEventArgs>(this)
                {
                    EventAction = (i, s, e) => i.Element_Click(s, e),
                    DetachAction = (i, w) => element.Click -= w.Handler,
                }.Handler;
                CalculateThrottled();
                if (BootStrapper.Current != null) BootStrapper.Current.ShellBackButtonUpdated += Current_ShellBackButtonUpdated;
                _deviceUtils = DeviceUtils.Current();
                if (_deviceUtils != null) _deviceUtils.Changed += DispositionChanged;
            }
        }