private void Source_TouchDown(Object sender, TouchEventArgs e) { Debug.WriteLine("Source_TouchDown(object sender, TouchEventArgs e)"); //TouchStarted = DateTime.Now; Timer touchTimer = new Timer(1); touchTimer.Elapsed += delegate { _targetMenu.Dispatcher.Invoke(new Action(() => { if (_targetMenu.IsOpen) { _wasOpenedWithTouch = true; AttachedProperties.SetOpenedWithTouch(_targetMenu, _wasOpenedWithTouch); //else if (!((e.OriginalSource as UIElement).AreAnyTouchesOver)) touchTimer.Stop(); } //if (_wasOpenedWithTouch) })); }; touchTimer.Start(); }
protected override void OnAttached() { _targetMenu = AssociatedObject; base.OnAttached(); _targetMenu.Opened += (sneder, args) => { //Debug.WriteLine("OpenedWithTouch: " + AttachedProperties.GetOpenedWithTouch(_targetMenu).ToString()); //Debug.WriteLine(args.Source.GetType().FullName); AttachedProperties.SetOpenedWithTouch(_targetMenu, _wasOpenedWithTouch); }; if (_targetMenu.IsLoaded) { Load(); } else { _targetMenu.Loaded += TargetMenu_Loaded; //_targetMenu.Initialized += TargetMenu_Initialized; _targetMenu.ApplyTemplate(); //_targetMenu.UpdateLayout(); } }