-
Notifications
You must be signed in to change notification settings - Fork 5
ChangeEventHandlerEventArgsType Xaml Mapping Action
This action is used assuming that the current property refers to an event handler.
The action will change the C# code behind by replacing the type of the second argument of the event handler. This argument is commonly known as the "event argument".
Property | Usage | Description |
---|---|---|
NewEventArgsTypeName | Required | The name of the type to be used as the type of the second argument of the event handler. |
One example where changing the type of the event arguments object is required is the conversion from UIElement.Tap event to UIElement.Tapped .
For example given the following code:
--Windows Phone Silverlight 8 XAML--
...
<Button Tap="MyHandler"/>
...
The code behind could look like this:
--Windows Phone Silverlight 8 C#--
...
void MyHandler(object sender, GestureEventArgs args)
{
...
}
...
We can write the mapping using the ChangeEventHandlerEventArgsType
code action as follows:
<xmap:XamlMap Kind="Property" PropertyName="Tap">
<xmap:XamlMap.Action>
<xmap:ActionSequence>
<xmap:ChangeEventHandlerEventArgsType NewEventArgsTypeName="Windows.UI.Xaml.Input.TappedRoutedEventArgs" />
<xmap:RenameProperty NewPropertyLocalName="Tapped" />
</xmap:ActionSequence>
</xmap:XamlMap.Action>
</xmap:XamlMap>
Applying the mapping above will generate the following code:
--Windows UWP XAML--
...
<Button Tapped="MyHandler"/>
...
The code behind could look like this:
--Windows UWP C#--
...
void MyHandler(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs args)
{
...
}
...
- The value of the 'NewEventArgsTypeName' attribute must be a valid C# type name.
- If the value of the 'NewEventArgsTypeName' has generic parameters then the following must be considered
- If the property is specified using the attribute syntax the
>
and<
entities must be used. For example:NewEventArgsTypeName="MyTypes<T>"
. - If the property is specified using the element syntax, a CDATA section can be used to specify the value. For example:
- If the property is specified using the attribute syntax the
<xmap:ChangeEventHandlerEventArgsType>
<xmap:ChangeEventHandlerEventArgsType.NewEventArgsTypeName>
<![CDATA[MyType<T>]]>
</xmap:ChangeEventHandlerEventArgsType.NewEventArgsTypeName>
</xmap:ChangeEventHandlerEventArgsType>
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