-
Notifications
You must be signed in to change notification settings - Fork 5
SetPropertyValueToComplexElement Xaml Mapping Action
ldfallas edited this page Aug 31, 2015
·
3 revisions
This action is used to set the value of an element to a complex value.
Complex value means that the property is specified using XAML.
Property | Usage | Description |
---|---|---|
TemplateContents | Content property / Required | The template for the generated Xaml property value |
We want to convert the Microsoft.Phone.Shell.ApplicationBarIconButton.IconUri to a element-style property that contains a BitmapIcon
element.
<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="ApplicationBarIconButton" 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:XamlMap Kind="Property" PropertyName="IconUri" >
<xmap:XamlMap.Action>
<xmap:ActionSequence>
<xmap:BindPropertyValueElement ContextKeyName="$URI" />
<xmap:SetPropertyValueToComplexElement >
<xmap:SetPropertyValueToComplexElement.TemplateContents>
<![CDATA[
<BitmapIcon UriSource="$URI" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"/>
]]>
</xmap:SetPropertyValueToComplexElement.TemplateContents>
</xmap:SetPropertyValueToComplexElement>
</xmap:ActionSequence>
</xmap:XamlMap.Action>
</xmap:XamlMap>
....
</xmap:XamlElementMapper>
</MapUnit.Elements>
</MapUnit>
Here the $URI
is being bound to the current value of the IconUri
property.
For example the following code
-- Windows Phone 8 Silverlight --
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar>
<shell:ApplicationBarIconButton IconUri="/Assets/Save.png" Text="xaa"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
Is converted to the following UWP code:
-- UWP --
<Page.BottomAppBar>
<CommandBar>
<AppBarButton Label="xaa">
<AppBarButton.Icon>
<BitmapIcon UriSource="/Assets/Save.png" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />
</AppBarButton.Icon>
</AppBarButton>
</CommandBar>
</Page.BottomAppBar>
- The contents of the property must be valid XAML. It is recommended to use a CDATA section to specify the value of this property.
- Variables must be referenced as a dollar sign '$' and a sequence of letters. For example $letter
- Template variables can only appear in:
- attribute bodies
- element bodies
- A template must be valid XML
- This action is commonly used in conjunction with the [BindPropertyValueElement Xaml mapping action](BindPropertyValueElement Xaml mapping action) which is used to bind variables
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