xaml - C# textbox keydown triggered twice in metro applications -
i m working on c# , xaml metro applications. have textbox , want once enter pressed in textbox new textbox appears. instead of 1 textbox, m getting 2 textboxes. did debugging n realized triggerd twice. not able figure out why triggerd twice. here code of application
private void textbox_keydown_1(object sender, windows.ui.xaml.input.keyroutedeventargs e) { if (e.key == windows.system.virtualkey.enter) { //code producing textbox } }
when m debugging, once above block executed, going layoutawarepage.cs , control sent ths code snippet
private void coredispatcher_acceleratorkeyactivated(coredispatcher sender, acceleratorkeyeventargs args) { var virtualkey = args.virtualkey; if ((args.eventtype == coreacceleratorkeyeventtype.systemkeydown || args.eventtype == coreacceleratorkeyeventtype.keydown) && (virtualkey == virtualkey.left || virtualkey == virtualkey.right || (int)virtualkey == 166 || (int)virtualkey == 167)) { var corewindow = window.current.corewindow; var downstate = corevirtualkeystates.down; bool menukey = (corewindow.getkeystate(virtualkey.menu) & downstate) == downstate; bool controlkey = (corewindow.getkeystate(virtualkey.control) & downstate) == downstate; bool shiftkey = (corewindow.getkeystate(virtualkey.shift) & downstate) == downstate; bool nomodifiers = !menukey && !controlkey && !shiftkey; bool onlyalt = menukey && !controlkey && !shiftkey; if (((int)virtualkey == 166 && nomodifiers) || (virtualkey == virtualkey.left && onlyalt)) { // when previous key or alt+left pressed navigate args.handled = true; this.goback(this, new routedeventargs()); } else if (((int)virtualkey == 167 && nomodifiers) || (virtualkey == virtualkey.right && onlyalt)) { // when next key or alt+right pressed navigate forward args.handled = true; this.goforward(this, new routedeventargs()); } } }
once ths code block done, control sent function textbox_keydown_1. m nt able understand why on first place control sent layoutawarepage.cs . code generated when added splitpage in project.
i had same problem, , found following article on msdn says ms aware of bug , has filed in internal database. suggestion of handling keyup instead of keydown worked situation.
Comments
Post a Comment