Skip to content

ActionSequence Xaml Mapping Action

ldfallas edited this page Aug 31, 2015 · 3 revisions

Description

Applies a sequence of mapping action to the current element.

This element acts as a container of XAML mapping actions.

Properties

Property ​ Usage ​Description
​Actions Content property The sequence of actions to be applied

Example

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:

  1. Replace the name of the Navigating XAML property to NavigationStarting
  2. Replace the type of the event handlers from NavigatingEventArgs to WebViewNavigationStartingEventArgs

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)
{
   ...
}
...

Notes

  • 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

Overview

Writing mappings

Code Mapping Actions

Code Mapping Conditions

XAML mapping actions

XAML mapping conditions

Misc

Clone this wiki locally