Skip to content

CommentOutProperty Xaml Mapping Action

ldfallas edited this page Aug 31, 2015 · 3 revisions

Description

Comments out the current property.

Properties

*No properties *

Example

Say that we want to comment out the TextBlock.FontFamily property when the value is a reference to the PhoneFontFamilySemiBold static resource.

For example:

<TextBlock Text="page name"  FontFamily="{StaticResource PhoneFontFamilySemiBold}"/>

The mapping could look 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="TextBlock" ElementNamespace="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
      <xmap:XamlElementMapper.Maps>
         ...
        <xmap:XamlMap Kind="Property" PropertyName="FontFamily" >
          <xmap:XamlMap.Action>
            <xmap:ActionSequence>
              <xmap:RemoveAttribute>
                <xmap:RemoveAttribute.Condition>
                  <xmap:PropertyUsesStaticResource PropertyName="FontFamily" StaticResourceName="PhoneFontFamilyNormal" />
                </xmap:RemoveAttribute.Condition>
              </xmap:RemoveAttribute>
              <xmap:CommentOutProperty>
                <xmap:CommentOutProperty.Condition>
                  <xmap:PropertyUsesStaticResource
                      PropertyName="FontFamily"
                      StaticResourceName="PhoneFontFamilySemiBold" />
                </xmap:CommentOutProperty.Condition>
              </xmap:CommentOutProperty>
            </xmap:ActionSequence>
          </xmap:XamlMap.Action>
        </xmap:XamlMap>
         ...
      </xmap:XamlElementMapper.Maps>

    </xmap:XamlElementMapper>
  </MapUnit.Elements>
</MapUnit>

The result of applying this mapping is the following:

--Windows UWP XAML--

<TextBlock Text="page name">
  <!--FontFamily="{StaticResource PhoneFontFamilySemiBold}"-->
</TextBlock>

Notes

  • This action will comment out properties specified using the attribute and element syntax.

Overview

Writing mappings

Code Mapping Actions

Code Mapping Conditions

XAML mapping actions

XAML mapping conditions

Misc

Clone this wiki locally