EventManager in silverlight app
When trying to use the following
EventManager.RegisterClassHandler(typeof(TextBox),
TextBox.GotFocusEvent,
new RoutedEventHandl开发者_开发百科er(TextBox_GotFocus));
I am getting an error on 2nd parameter: "'System.Windows.Controls.TextBox' does not contain a definition for 'GotFocusEvent'"
Any help how to resolve this?
I am in the process of adding "Select All" behaviour for all TextBox in my silverlight app and by having this at Application_Startup in App.xaml.cs I thought would do the trick.
Thanks in advance.
I can't find an EventManager class in the Silverlight documentation?
I'm fairly sure that Silverlight does not support Class Handlers.
The closest you are going to get is to place a handler for GotFocus
on some element that contains these TextBoxes and test the OriginalSource
property to see if it is of type TextBox
.
TextBox doesn't define the static member GotFocusEvent
but UIElement does.
Try replacing TextBox
with UIElement
like so:
EventManager.RegisterClassHandler(typeof(TextBox),
UIElement.GotFocusEvent,
new RoutedEventHandler(TextBox_GotFocus));
精彩评论