Skip to content

RenameElement Xaml Mapping Action

ldfallas edited this page Aug 31, 2015 · 3 revisions

Description

Changes the name or namespace of an element .

Properties

​Property ​Description
​NewName ​The new "local name" of the element
​NewNamespace ​The new XML namespace of the element

Examples

Say that we want to rename the Windows Phone WebBrowser control usages to the UWP WebView control .

For example

** ---- Source Windows Phone Silverlight XAML ----**

<phone:PhoneApplicationPage
    x:Class="ConverterDemoApp.MainPage"
    ...
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    ...
    >
   ...
  <phone:WebBrowser x:Name="myWebBrowser"/>
   ...
</phone:PhoneApplicationPage>

---- Windows Phone To UWP converter XAML mapping ----

<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="Element">
                    <xmap:XamlMap.Action>
                        <xmap:RenameElement NewName="WebView"
                                            NewNamespace="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />
                    </xmap:XamlMap.Action>
                </xmap:XamlMap>
            </xmap:XamlElementMapper.Maps>
        </xmap:XamlElementMapper>
    </MapUnit.Elements>
</MapUnit>

After applying this mapping the code will look like this:

   <Page x:Class="ConverterDemoApp.MainPage"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   ...>
   ...
        <WebView x:Name="myWebBrowser" />
   ...
</Page>

Notes

TODO

Overview

Writing mappings

Code Mapping Actions

Code Mapping Conditions

XAML mapping actions

XAML mapping conditions

Misc

Clone this wiki locally