-
Notifications
You must be signed in to change notification settings - Fork 5
WritingXamlMappings
Windows Phone 8.0 Silverilght uses XAML to describe pages and user controls. These XAML files have references to controls and code tied to the Windows Phone platform.
The UWP conversion tool provides a mechanism for creating mappings of Xaml code. These mappings are stored in '.xmap' files . The following code shows an example of a Xaml mapping file:
<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: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.ReferencedPackages>
<x:String>CommonEventsToChange</x:String>
</xmap:XamlElementMapper.ReferencedPackages>
</xmap:XamlElementMapper>
</MapUnit.Elements>
</MapUnit>
The previous mapping definition shows the definition of a MapUnit
that contains a mapping for the WebBrowser
control .
A "Map unit" is a container of mappings for Windows Phone Xaml elements.
An empty "Map unit" looks like this:
<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>
...
</MapUnit.Elements>
</MapUnit>
The XamlElementMapper
element defines mappings for a XAML element. An empty mapper for the WebBrowser
control (https://msdn.microsoft.com/en-us/library/windows/apps/microsoft.phone.controls.webbrowser%28v=vs.105%29.aspx) looks like this:
...
<xmap:XamlElementMapper ElementName="WebBrowser"
ElementNamespace="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone">
<xmap:XamlElementMapper.Maps>
...
</xmap:XamlElementMapper.Maps>
</xmap:XamlElementMapper>
...
Inside XamlElementMapper
we can define mappings for the current element . For example the equivalent control to WebBrowser
is the WebView
control (https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.webview.aspx) . We can write a mapping for the element name as follows:
<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>
Mappings are used to apply mapping actions for example in this case use used the RenameElement Xaml Mapping Action.
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