wpf - c# InvalidEnumArgumentException: The value of argument 'direction' (3) is invalid for Enum type 'FocusNavigationDirection' -


i have wpf-c# application ribbon menu , several text box main panel. when focus 1 of them , press left arrow, following error. when press on other arrow works well. tried breakpoint on previewkeydoyn of specific textbox method exception thrown before can ran it.

all other textbox in application work when press left arrow.

system.componentmodel.invalidenumargumentexception: la valeur de l'argument 'direction' (3) n'est pas valide pour le type enum 'focusnavigationdirection'. nom du paramètre : direction    à system.windows.input.keyboardnavigation.isindirection(rect fromrect, rect torect, focusnavigationdirection direction)    à system.windows.input.keyboardnavigation.findnextindirection(dependencyobject sourceelement, rect sourcerect, dependencyobject container, focusnavigationdirection direction, double startrange, double endrange)    à system.windows.input.keyboardnavigation.movenext(dependencyobject sourceelement, dependencyobject container, focusnavigationdirection direction, double startrange, double endrange)    à system.windows.input.keyboardnavigation.getnextindirection(dependencyobject sourceelement, focusnavigationdirection direction)    à system.windows.input.keyboardnavigation.predictfocusedelement(dependencyobject sourceelement, focusnavigationdirection direction)    à system.windows.frameworkelement.predictfocus(focusnavigationdirection direction)    à microsoft.windows.controls.ribbon.ribbonhelper.predictfocus(dependencyobject element, focusnavigationdirection direction) dans e:\dd\wpfoob\src\wpfoob\ribbon\ribboncontrolslibrary\microsoft\windows\controls\ribbon\ribbonhelper.cs:ligne 488    à microsoft.windows.controls.ribbon.ribbonapplicationmenu.onpreviewkeydown(keyeventargs e) dans e:\dd\wpfoob\src\wpfoob\ribbon\ribboncontrolslibrary\microsoft\windows\controls\ribbon\ribbonapplicationmenu.cs:ligne 520    à system.windows.uielement.onpreviewkeydownthunk(object sender, keyeventargs e)    à system.windows.input.keyeventargs.invokeeventhandler(delegate generichandler, object generictarget)    à system.windows.routedeventargs.invokehandler(delegate handler, object target)    à system.windows.routedeventhandlerinfo.invokehandler(object target, routedeventargs routedeventargs)    à system.windows.eventroute.invokehandlersimpl(object source, routedeventargs args, boolean reraised)    à system.windows.uielement.raiseeventimpl(dependencyobject sender, routedeventargs args)    à system.windows.uielement.raisetrustedevent(routedeventargs args)    à system.windows.uielement.raiseevent(routedeventargs args, boolean trusted)    à system.windows.input.inputmanager.processstagingarea()    à system.windows.input.inputmanager.processinput(inputeventargs input)    à system.windows.input.inputprovidersite.reportinput(inputreport inputreport)    à system.windows.interop.hwndkeyboardinputprovider.reportinput(intptr hwnd, inputmode mode, int32 timestamp, rawkeyboardactions actions, int32 scancode, boolean isextendedkey, boolean issystemkey, int32 virtualkey)    à system.windows.interop.hwndkeyboardinputprovider.processkeyaction(msg& msg, boolean& handled)    à system.windows.interop.hwndsource.criticaltranslateaccelerator(msg& msg, modifierkeys modifiers)    à system.windows.interop.hwndsource.onpreprocessmessage(object param)    à system.windows.threading.exceptionwrapper.internalrealcall(delegate callback, object args, int32 numargs)    à ms.internal.threading.exceptionfilterhelper.trycatchwhen(object source, delegate method, object args, int32 numargs, delegate catchhandler) 

i decompiled ribboncontrolslibrary.dll assembly .net reflector , found part of code. if carefully, can see right, up, down , last used. should left instead of last. way resolve problem use .net framework 4.5 or override onpreviewkeydown handle left key (so exception not thrown caret don't move previous character).

my code:

protected override void onpreviewkeydown(keyeventargs e) {     if (e.key == key.left)     {         e.handled = true;     } } 

ribboncontrolslibrary.dll:

protected override void onpreviewkeydown(keyeventargs e) {     if (!e.handled)     {         dependencyobject originalsource;         dependencyobject obj3;         if (e.key == key.down)         {             originalsource = e.originalsource dependencyobject;             if (originalsource != null)             {                 uielement footerpanehost = this.footerpanehost;                 if (((footerpanehost != null) && footerpanehost.iskeyboardfocuswithin) && treehelper.isvisualancestorof(footerpanehost, originalsource))                 {                     obj3 = ribbonhelper.predictfocus(originalsource, focusnavigationdirection.down);                     if (((obj3 == null) || (obj3 == originalsource)) && (this.itemspanemovefocus(focusnavigationdirection.first) || this.auxiliarypanemovefocus(focusnavigationdirection.first)))                     {                         e.handled = true;                     }                 }             }         }         else         {             uielement auxiliarypanehost;             if (e.key == key.up)             {                 uielement element2 = this._popup.trygetchild();                 if ((element2 != null) && !element2.iskeyboardfocuswithin)                 {                     if (this.footerpanemovefocus(focusnavigationdirection.last) || this.auxiliarypanemovefocus(focusnavigationdirection.last))                     {                         e.handled = true;                     }                 }                 else                 {                     originalsource = e.originalsource dependencyobject;                     if (originalsource != null)                     {                         auxiliarypanehost = this.auxiliarypanehost;                         if (((auxiliarypanehost != null) && auxiliarypanehost.iskeyboardfocuswithin) && treehelper.isvisualancestorof(auxiliarypanehost, originalsource))                         {                             obj3 = ribbonhelper.predictfocus(originalsource, focusnavigationdirection.up);                             if (((obj3 == null) || (obj3 == originalsource)) && (this.itemspanemovefocus(focusnavigationdirection.last) || this.footerpanemovefocus(focusnavigationdirection.last)))                             {                                 e.handled = true;                             }                         }                     }                 }             }             else if ((e.key == key.left) || (e.key == key.right))             {                 originalsource = e.originalsource dependencyobject;                 if (originalsource != null)                 {                     if ((e.key == key.left) == (base.flowdirection == flowdirection.lefttoright))                     {                         auxiliarypanehost = this.auxiliarypanehost;                         if (((auxiliarypanehost != null) && auxiliarypanehost.iskeyboardfocuswithin) && treehelper.isvisualancestorof(auxiliarypanehost, originalsource))                         {                             obj3 = ribbonhelper.predictfocus(originalsource, focusnavigationdirection.last);                             if (((obj3 != null) && !treehelper.isvisualancestorof(auxiliarypanehost, obj3)) && ribbonhelper.focus(obj3))                             {                                 e.handled = true;                             }                         }                     }                     else if (e.key == key.left)                     {                         scrollviewer submenuscrollviewer = base.submenuscrollviewer;                         if (((submenuscrollviewer != null) && submenuscrollviewer.iskeyboardfocuswithin) && treehelper.isvisualancestorof(submenuscrollviewer, originalsource))                         {                             ribbonmenuitem item = originalsource ribbonmenuitem;                             if (item == null)                             {                                 item = treehelper.findvisualancestor<ribbonmenuitem>(originalsource);                             }                             if ((item != null) && !item.canopensubmenu)                             {                                 obj3 = item.predictfocus(focusnavigationdirection.right);                                 if ((obj3 != null) && ribbonhelper.focus(obj3))                                 {                                     e.handled = true;                                 }                             }                         }                     }                 }             }         }         base.onpreviewkeydown(e);     } } 

focusnavigationdirection:

public enum focusnavigationdirection {     // résumé :     //     déplacer le focus sur l'élément pouvant être actif suivant dans l'ordre de     //     tabulation.non pris en charge pour system.windows.uielement.predictfocus(system.windows.input.focusnavigationdirection).     next = 0,     //     // résumé :     //     déplacer le focus sur l'élément pouvant être actif précédent dans l'ordre     //     de tabulation.non pris en charge pour system.windows.uielement.predictfocus(system.windows.input.focusnavigationdirection).     previous = 1,     //     // résumé :     //     déplacer le focus sur le premier élément pouvant être actif dans l'ordre     //     de tabulation.non pris en charge pour system.windows.uielement.predictfocus(system.windows.input.focusnavigationdirection).     first = 2,     //     // résumé :     //     déplacer le focus sur le dernier élément pouvant être actif dans l'ordre     //     de tabulation.non pris en charge pour system.windows.uielement.predictfocus(system.windows.input.focusnavigationdirection).     last = 3,     //     // résumé :     //     déplacer le focus sur un autre élément pouvant être actif et situé à gauche     //     de l'élément ayant actuellement le focus.     left = 4,     //     // résumé :     //     déplacer le focus sur un autre élément pouvant être actif et situé à droite     //     de l'élément ayant actuellement le focus.     right = 5,     //     // résumé :     //     déplacer le focus sur un autre élément pouvant être actif et situé plus haut     //     par rapport à l'élément ayant actuellement le focus.     = 6,     //     // résumé :     //     déplacer le focus sur un autre élément pouvant être actif et situé plus bas     //     par rapport à l'élément ayant actuellement le focus.     down = 7, } 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -