c# - WPF Touch - MouseDoubleClick - Opening Window - have to click once to do anything -


spent last few hours trying in vain ..

i've created sample application replicates behaviour. have button in mainwindow on mousedoubleclick() event, opens window. window contains simple button close said window. code looks this:

private void button_onmousedoubleclick(object sender, mousebuttoneventargs e) {     var window2 = new window1();     window2.showdialog(); } 

once window opens, attempt close single-clicking on button. fails. clicking once seems "selecting" button because highlights blue, , once click second time it's event fire. if double click, open window, click anywhere in window - event fires.

this doesn't affect buttons. if there input fields in window, have click twice go control.

this happens on tablets. mouse-clicking fine.

code i've tried , doesn't work:

private void button_copy4_onmousedoubleclick(object sender,mousebuttoneventargs e)     {         e.handled = checkbox.ischecked.value;         var window = new window1();         action showaction = () =>         {             window.showdialog();         };         this.dispatcher.begininvoke(showaction);     }      private void button_copy5_onmousedoubleclick(object sender,         mousebuttoneventargs e)     {         e.handled = checkbox.ischecked.value;          var window = new window1();         action showaction = () =>         {             window.showdialog();         };         this.dispatcher.begininvoke(showaction);     }      private void button_copy8_onmousedoubleclick(object sender,         mousebuttoneventargs e)     {         e.handled = checkbox.ischecked.value;         var window = new window1();         window.owner = this;         window.topmost = true;         window.showdialog();     }      private void button_copy10_onmousedoubleclick(object sender,         mousebuttoneventargs e)     {         e.handled = checkbox.ischecked.value;         thread.sleep(100);         var window = new window1();         action showaction = () =>         {             window.showdialog();         };         this.dispatcher.begininvoke(showaction);     } 

only code works:

    private void button_copy9_onmousedoubleclick(object sender,         mousebuttoneventargs e)     {         e.handled = checkbox.ischecked.value;         var window = new window1();         action showaction = () =>         {             window.show();         };         this.dispatcher.begininvoke(showaction);     }      private void button_copy11_onmousedoubleclick(object sender,         mousebuttoneventargs e)     {         var window = new window1();         system.threading.tasks.task.factory.startnew(             () => { system.threading.thread.sleep(100); })         .continuewith(             task =>             {                 application.current.dispatcher.invoke(                     () => { window.showdialog(); });             });     } 


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -