Skip to content

Writing conditional Xaml Mappings

ldfallas edited this page Aug 17, 2015 · 2 revisions

Mapping actions for Xaml documents can be applied conditionally. Each action has a property which is the condition it need to meet before applying any action.

For example the following Xaml property mapping will remove the FontFamily property from an element if the current property uses the PhoneFontFamilyNormal static resource.

...
<xmap:XamlMap Kind="Property" PropertyName="FontFamily" >
   <xmap:XamlMap.Action>
      <xmap:RemoveAttribute>
         <xmap:RemoveAttribute.Condition>
            <xmap:PropertyUsesStaticResource PropertyName="FontFamily"
                                             StaticResourceName="PhoneFontFamilyNormal" />
         </xmap:RemoveAttribute.Condition>
      </xmap:RemoveAttribute>
   </xmap:XamlMap.Action>
</xmap:XamlMap>
...

In this case we used the Condition property of the Xaml mapping actions.

Overview

Writing mappings

Code Mapping Actions

Code Mapping Conditions

XAML mapping actions

XAML mapping conditions

Misc

Clone this wiki locally