![]() ![]() If you want your whole application to work that way, makwana.a's answer is better but can be improved.īelow is my modification of makwana.a's answer, which I have used in numerous applications. If you only want it to work for a few text boxes, Jay's answer is best. I'd advise against it, as it is a common, well known paradigm, but if that is the case, you can add a PreviewKeyDown handler in the attached property, check for the tab key, and set Handled = true for the event args. You also said "instead of tab," so I'm wondering if you want to suppress the ability to use tab in the usual way. ![]() If(element != null) element.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)) Static void Keydown(object sender, KeyEventArgs e) If ((bool)e.NewValue) element.KeyDown += Keydown Static void OnAdvancesByEnterKeyPropert圜hanged(DependencyObject d, DependencyPropert圜hangedEventArgs e) New UIPropertyMetadata(OnAdvancesByEnterKeyPropert圜hanged)) Public static readonly DependencyProperty AdvancesByEnterKeyProperty =ĭependencyProperty.RegisterAttached("AdvancesByEnterKey", typeof(bool), typeof(FocusAdvancement), Obj.SetValue(AdvancesByEnterKeyProperty, value) Public static void SetAdvancesByEnterKey(DependencyObject obj, bool value) Return (bool)obj.GetValue(AdvancesByEnterKeyProperty) Public static bool GetAdvancesByEnterKey(DependencyObject obj) The attached property: public static class FocusAdvancement (UI is the namespace alias for where I've defined the following.) Below is an attached property that I've used for just this. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |