Skip to content

MoveValueToContentProperty Xaml Mapping Action

ldfallas edited this page Aug 31, 2015 · 3 revisions

Usage

<xmap:MoveValueToContentProperty/>

Description

Moves the value of the current property to the content property of the current element.

Properties

​Property ​Usage ​Description
AtTheEnd Optional True or False value that determines if the the element is added at the end

Example

For this example we want to move the value of two properties to the content property of the target element.

We're going to take the Header and Items property of the ExpanderView control and move them to the content property wrapped in a Stack panel.

The mapping 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>
        <xmap:XamlElementMapper ElementName="ExpanderView" ElementNamespace="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit">
            <xmap:XamlElementMapper.Maps>
              <xmap:XamlMap Kind="Property" PropertyName="Header" >
                <xmap:XamlMap.Action>
                  <xmap:ActionSequence>
                    <xmap:WrapContent WrappingElementName="StackPanel"
                                      WrappingElementNamespace="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />
                    <xmap:MoveValueToContentProperty  />
                  </xmap:ActionSequence>
                </xmap:XamlMap.Action>
              </xmap:XamlMap>
                <xmap:XamlMap Kind="Property" PropertyName="Items" >
                    <xmap:XamlMap.Action>
                      <xmap:ActionSequence>
                        <xmap:WrapContent WrappingElementName="StackPanel"
                                          WrappingElementNamespace="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />
                        <xmap:MoveValueToContentProperty AtTheEnd="true" />
                      </xmap:ActionSequence>
                    </xmap:XamlMap.Action>
                </xmap:XamlMap>
              <xmap:XamlMap Kind="Property" PropertyName="IsExpanded" >
                <xmap:XamlMap.Action>
                  <xmap:MarkAsNotMapped ElementName="ExpanderView"/>
                </xmap:XamlMap.Action>
              </xmap:XamlMap>
              <xmap:XamlMap Kind="Element">
                <xmap:XamlMap.Action>
                  <xmap:RenameElement NewName="StackPanel" NewNamespace="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />
                </xmap:XamlMap.Action>
              </xmap:XamlMap>
            </xmap:XamlElementMapper.Maps>
        </xmap:XamlElementMapper>
    </MapUnit.Elements>
</MapUnit>

Given the following code:

-- Windows Phone 8 Silverlight --

<tk:ExpanderView>
    <tk:ExpanderView.Header>
        <TextBlock>Hello</TextBlock>
    </tk:ExpanderView.Header>
    <tk:ExpanderView.Items>
        <TextBlock>World</TextBlock>
    </tk:ExpanderView.Items>
</tk:ExpanderView>

We get the following converted code:

--Windows UWP--

<StackPanel>
  <StackPanel>
    <TextBlock>Hello</TextBlock>
  </StackPanel>
  <StackPanel>
    <TextBlock>World</TextBlock>
  </StackPanel>
</StackPanel>

Notes

  • This mapping action can only be used in a XamlMap of kind Property.

Overview

Writing mappings

Code Mapping Actions

Code Mapping Conditions

XAML mapping actions

XAML mapping conditions

Misc

Clone this wiki locally