-
Notifications
You must be signed in to change notification settings - Fork 5
RenameProperty Xaml Mapping Action
ldfallas edited this page Aug 17, 2015
·
2 revisions
Renames a property of a Xaml element
Property | Usage | Description |
---|---|---|
NewPropertyLocalName | Required | The new name of the property |
NewXmlNamespaceName | Optional | The new XML namespace of the property (may be used for attached properties) |
Say that we want to convert the 'Text' property of the 'ApplicationBarMenuItem' control to the 'Label' property of the 'AppBarButton' control on UWP.
<shell:ApplicationBar>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="text for menu item 1" />
<shell:ApplicationBarMenuItem >
<shell:ApplicationBarMenuItem.Text>
Some other text for menu item 2
</shell:ApplicationBarMenuItem.Text>
</shell:ApplicationBarMenuItem>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
The mapper definition is the following:
<xmap:XamlElementMapper ElementName="ApplicationBarMenuItem" ElementNamespace="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">
<xmap:XamlElementMapper.Maps>
<xmap:XamlMap Kind="Element">
<xmap:XamlMap.Action>
<xmap:RenameElement NewName="AppBarButton" NewNamespace="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />
</xmap:XamlMap.Action>
</xmap:XamlMap>
<xmap:XamlMap Kind="Property" PropertyName="Text" >
<xmap:XamlMap.Action>
<xmap:RenameProperty NewPropertyLocalName="Label" />
</xmap:XamlMap.Action>
</xmap:XamlMap>
</xmap:XamlElementMapper.Maps>
<xmap:XamlElementMapper.ReferencedPackages>
<x:String>CommonEventsToChange</x:String>
</xmap:XamlElementMapper.ReferencedPackages>
</xmap:XamlElementMapper>
By applying this mapping we get the following output
<CommandBar>
<CommandBar.SecondaryCommands>
<AppBarButton Label="text for menu item 1" />
<AppBarButton>
<AppBarButton.Label>
Some other text for menu item 2
</AppBarButton.Label>
</AppBarButton>
</CommandBar.SecondaryCommands>
</CommandBar>
This action can be used to rename both attribute and element properties (see the example above).
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