c# - The name 'Key' does not exist in the current context -
c# - The name 'Key' does not exist in the current context -
i new windows app programming. want capture input of textbox after user presses homecoming key. maintain getting error "the name 'key' not exist in current context." have added 'using system.windows.input;' still same error. missing?
using app1.common; using system; using system.windows.input; using system.collections.generic; using system.io; using system.linq; using system.runtime.interopservices.windowsruntime; using windows.foundation; using windows.foundation.collections; using windows.ui.xaml; using windows.ui.xaml.controls; using windows.ui.xaml.controls.primitives; using windows.ui.xaml.data; using windows.ui.xaml.input; using windows.ui.xaml.media; using windows.ui.xaml.navigation; // basic page item template documented @ http://go.microsoft.com/fwlink/?linkid=234237 namespace app1 { /// <summary> /// basic page provides characteristics mutual applications. /// </summary> public sealed partial class mainpage : page { private navigationhelper navigationhelper; private observabledictionary defaultviewmodel = new observabledictionary(); /// <summary> /// can changed typed view model. /// </summary> public observabledictionary defaultviewmodel { { homecoming this.defaultviewmodel; } } /// <summary> /// navigationhelper used on each page aid in navigation , /// process lifetime management /// </summary> public navigationhelper navigationhelper { { homecoming this.navigationhelper; } } public mainpage() { this.initializecomponent(); this.navigationhelper = new navigationhelper(this); this.navigationhelper.loadstate += navigationhelper_loadstate; this.navigationhelper.savestate += navigationhelper_savestate; } /// <summary> /// populates page content passed during navigation. saved state /// provided when recreating page prior session. /// </summary> /// <param name="sender"> /// source of event; typically <see cref="navigationhelper"/> /// </param> /// <param name="e">event info provides both navigation parameter passed /// <see cref="frame.navigate(type, object)"/> when page requested , /// dictionary of state preserved page during before /// session. state null first time page visited.</param> private void navigationhelper_loadstate(object sender, loadstateeventargs e) { } /// <summary> /// preserves state associated page in case application suspended or /// page discarded navigation cache. values must conform serialization /// requirements of <see cref="suspensionmanager.sessionstate"/>. /// </summary> /// <param name="sender">the source of event; typically <see cref="navigationhelper"/></param> /// <param name="e">event info provides empty dictionary populated /// serializable state.</param> private void navigationhelper_savestate(object sender, savestateeventargs e) { } #region navigationhelper registration /// methods provided in section used allow /// navigationhelper respond page's navigation methods. /// /// page specific logic should placed in event handlers /// <see cref="gridcs.common.navigationhelper.loadstate"/> /// , <see cref="gridcs.common.navigationhelper.savestate"/>. /// navigation parameter available in loadstate method /// in add-on page state preserved during before session. protected override void onnavigatedto(navigationeventargs e) { navigationhelper.onnavigatedto(e); } protected override void onnavigatedfrom(navigationeventargs e) { navigationhelper.onnavigatedfrom(e); } #endregion private void button_click(object sender, routedeventargs e) { greetingoutput.text = "hello, " + nameinput.text + "!"; } private void item1_keydown(object sender, keyroutedeventargs e) { if (e.key == key.return) { } } } }
if take @ msdn library article on keyroutedeventargs
see key
property virtualkey
enumeration. looking @ enumerations available there not return there enter
enter|enter 13 come in key.
and in looking illustration in first link want this
if (e.key == windows.system.virtualkey.enter) { .... }
c# windows xaml
Comments
Post a Comment