-
Notifications
You must be signed in to change notification settings - Fork 5
Writing a mapping for event handlers
With the change to UWP some event handlers need to be changed . For example:
...
<TextBlock Tap="TextBlock_Tap">Some text</TextBlock>
...
In this case the Windows Phone Silverlight's System.Windows.UIElement.Tap event (https://msdn.microsoft.com/en-us/library/system.windows.uielement.tap(v=vs.95).aspx) is being used. The event handler in this case looks like this:
private void TextBlock_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
MessageBox.Show("Hello!");
}
In order to convert this code to UWP we need to change from the 'Tap' event to the Windows.UI.Xaml.UIElement.Tapped (https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.uielement.tapped) event .
The target UWP code may look like this:
<TextBlock Tapped="TextBlock_Tap">Some text</TextBlock>
The event handler signature must also be changed. Here's the expected code:
private async void TextBlock_Tap(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
{
await (new Windows.UI.Popups.MessageDialog("Hello!")).ShowAsync();
}
TODO
Contact us for more information
Overview
Writing mappings
Code Mapping Actions
- ActionSequence
- AddHelper
- AddNamespaceImport
- AddPreStatementFromTemplate
- CommentOut
- Conditional
- Keep Code Mapping Action
- MarkAsNotMapped
- RedirectCall
- RedirectCallToInnerMember
- RedirectIndexer
- RedirectProperty
- RemoveCurrentStatement
- RemoveParameter
- ReplaceClassUsage
- ReplaceMethodBodyWithTemplate
- ReplaceParameterDeclarationType
- ReplaceParameterMember
- ReplaceParameterValue
- ReplaceWithMethodCall
- ReplaceWithProperty
- ReplaceWithTemplate
Code Mapping Conditions
- AllConditionsApply
- ArgumentCount
- AssignName
- AssignNameToArgumentRange
- IsExpressionOfType
- IsStringLiteralMatchingRegex
- WithArgument
- WithAssignment
- WithAssignmentLeftSide
- WithAssignmentRightSide
- WithCalledMemberOwner
- WithCalledMethodExpression
- WithConstructorCall
- WithLambdaExpressionBody
- WithLambdaExpressionParameter
- WithLeftSideOfDottedAccess
- WithMemberInitValue
- WithMethodCall
XAML mapping actions
- ActionSequence
- AddStatementToConstructorFromTemplate
- BindPropertyValueElement Xaml mapping action
- ChangeEventHandlerEventArgsType
- CommentOutElement
- CommentOutProperty
- MarkAsNotMapped
- MoveValueToContentProperty
- RemoveNamespaceDeclaration
- RenameElement
- RenameProperty
- ReplaceAttributeValue
- ReplaceEventHandlerBodyWithTemplate
- ReplaceEventHandlerParameterMember
- ReplaceNamespaceDeclaration
- ReplacePropertyValueWithParentResource
- ReplaceStaticResourceWithThemeResource
- SetPropertyValueToComplexElement
- SetPropertyValueToSimpleValue
- WrapContent
XAML mapping conditions
Misc