-
Notifications
You must be signed in to change notification settings - Fork 5
ActionSequence Xaml Mapping Action
Applies a sequence of mapping action to the current element.
This element acts as a container of XAML mapping actions.
Property | Usage | Description |
---|---|---|
Actions | Content property | The sequence of actions to be applied |
This mapping action is useful when several action must be performed in order to migrate an element.
For example the Navigating
event Microsoft.Phone.Controls.WebBrowser
of the control.
-- Windows Phone 8 Silverlight XAML--
...
<phone:WebBrowser Navigating="MyNavigatingHandler" />
...
As shown above, there's an event handler for the Navigating
event. This event handler uses the NavigatingEventArgs class as its event argument class. Since this class is not available on UWP we need to convert it.
-- Windows Phone 8 Silverlight C#--
...
public void MyNavigatingHandler(object sender,NavigatingEventArgs args)
{
...
}
...
This code needs to be converted to the WebView.NavigationStarting. To do this conversion we need to do at least two operations:
- Replace the name of the
Navigating
XAML property toNavigationStarting
- Replace the type of the event handlers from
NavigatingEventArgs
toWebViewNavigationStartingEventArgs
These two operations could be applied using the [ChangeEventHandlerEventArgsType Xaml Mapping action](ChangeEventHandlerEventArgsType Xaml Mapping action) and the [RenameProperty Xaml Mapping Action](RenameProperty Xaml Mapping Action) . And we can combine these two operations using the ActionSequence
action as follows:
<MapUnit xmlns='clr-namespace:Mobilize.Mappers.Extensibility.Core;assembly=Mobilize.ExtensibleMappers'
xmlns:xmap='clr-namespace:Mobilize.XamlMappers;assembly=Mobilize.XamlMapper'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' >
<MapUnit.Elements>
<xmap:XamlElementMapper ElementName="WebBrowser"
ElementNamespace="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone">
<xmap:XamlElementMapper.Maps>
...
<xmap:XamlMap Kind="Property" PropertyName="Navigating">
<xmap:XamlMap.Action>
<xmap:ActionSequence>
<xmap:ChangeEventHandlerEventArgsType NewEventArgsTypeName="Windows.UI.Xaml.Controls.WebViewNavigationStartingEventArgs" />
<xmap:RenameProperty NewPropertyLocalName="NavigationStarting" />
</xmap:ActionSequence>
</xmap:XamlMap.Action>
</xmap:XamlMap>
</xmap:XamlElementMapper.Maps>
...
</xmap:XamlElementMapper>
</MapUnit.Elements>
</MapUnit>
Executing the conversion tool again will generate the following UWP code:
**-- UWP XAML--**
...
<WebView NavigationStarting="MyNavigatingHandler" />
...
As shown above, there's an event handler for the Navigating
event. This event handler uses the NavigatingEventArgs class as its event argument class. Since this class is not available on UWP we need to convert it.
-- UWP C#--
...
public void MyNavigatingHandler(object sender,Windows.UI.Xaml.Controls.WebViewNavigationStartingEventArgs args)
{
...
}
...
- It is important to stress that the XAML mapping operations are destructive. Because of this it's important to leave the
RenameProperty
operation at the end of the mapping action sequence
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