-
Notifications
You must be signed in to change notification settings - Fork 5
ReplacePropertyValueWithParentResource Xaml Mapping Action
ldfallas edited this page Aug 31, 2015
·
3 revisions
<map:ReplacePropertyValueWithParentResource>
<ReplacePropertyValueWithParentResource.ReplacementTemplateContents>
...XAML TEMPLATE...
</ReplacePropertyValueWithParentResource.ReplacementTemplateContents>
</map:ReplacePropertyValueWithParentResource>
This XAML mapping action replaces the value of the property with a static resource.
Property | Usage | Description |
---|---|---|
ReplacementTemplateContents | Content property | A XAML template with the value of the new resource being generated |
Say for example that we want to move all the 'Content' properties of buttons to a static resource.
We can write the following 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="Button" ElementNamespace="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<xmap:XamlElementMapper.Maps>
...
<xmap:XamlMap Kind="Property" PropertyName="Content">
<xmap:XamlMap.Action>
<xmap:ActionSequence>
<xmap:BindPropertyValueElement ContextKeyName="$CONTENT" />
<xmap:ReplacePropertyValueWithParentResource >
<xmap:ReplacePropertyValueWithParentResource.ReplacementTemplateContents>
<![CDATA[<x:String xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>$CONTENT</x:String>]]>
</xmap:ReplacePropertyValueWithParentResource.ReplacementTemplateContents>
</xmap:ReplacePropertyValueWithParentResource>
</xmap:ActionSequence>
</xmap:XamlMap.Action>
</xmap:XamlMap>
...
</xmap:XamlElementMapper.Maps>
...
</xmap:XamlElementMapper>
</MapUnit.Elements>
</MapUnit>
By applying this mapping to this source code:
--Windows Phone 8 Silverlight --
<Button Click="Button_Click" Content="Ok" ></Button>
We get the following code:
--Windows UWP--
<Page ...>
<Page.Resources>
<x:String xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Key="ContentResource">Ok</x:String>
</Page.Resources>
<Button Click="Button_Click" Content="{Binding Source={StaticResource ContentResource }}"></Button>
</Page>
- The value of the
ReplacementTemplateContents
must be a valid XAML string
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