Skip to content

Writting mappings for XAML attached properties

ldfallas edited this page Aug 31, 2015 · 2 revisions

To write a mapping for an attached property we need to define a XAML mapping the element and property that needs to be converted.

For example, say that we want to comment out uses of the TiltEffect.IsTiltEnabled property.

We can define a mapping as follows:

<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="TiltEffect"
                            ElementNamespace="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit">
      <xmap:XamlElementMapper.Maps>
        <xmap:XamlMap Kind="Property" PropertyName="IsTiltEnabled" >
          <xmap:XamlMap.Action>
              <xmap:CommentOutProperty />
          </xmap:XamlMap.Action>
        </xmap:XamlMap>
      </xmap:XamlElementMapper.Maps>
    </xmap:XamlElementMapper>
  </MapUnit.Elements>
</MapUnit>

When registering this mapping it can be applied to any use of the property, for example:

--Windows Phone Silverlight--

<phone:PhoneApplicationPage ... toolkit:TiltEffect.IsTiltEnabled="True"  >
   ...
</phone:PhoneApplicationPage>

It will be transformed to:

--Windows UWP--

<Page ...>
  <!--toolkit:TiltEffect.IsTiltEnabled="True"-->
</Page>

Overview

Writing mappings

Code Mapping Actions

Code Mapping Conditions

XAML mapping actions

XAML mapping conditions

Misc

Clone this wiki locally