XAML Refactoring

Autogenerated by MFractor v3.7.3

Add Transparency Channel To Color

Professional Only

Configuration Id: com.mfractor.code_actions.xaml.add_transparency_to_color

Given a color literal defined by a hex value, this code action adds a transparency channel to that color.

Convert Named Color To Hexadecimal

Professional Only

Configuration Id: com.mfractor.code_actions.xaml.convert_named_color_to_hexadecimal

Given a color that is defined by a named color literal (such as Red, Green etc), this code action converts that

Convert StackLayout To Grid

Professional Only

Configuration Id: com.mfractor.code_actions.xaml.convert_stacklayout_to_grid

User the Convert StackLayout To Grid refactoring to change a StackLayout layout to a Grid

Given a StackLayout in XAML, this code action converts it to a vertically or horizontally aligned grid.

Uses:

Edit Color Declaration

Professional Only

Configuration Id: com.mfractor.code_actions.xaml.edit_color

Use the Edit Color code action to visually edit a color from your Xaml.

The Edit Color Declaration code actions allows visual editing of colors from your Xaml.

Simply right click on a Xaml node that is a System.Drawing.Color or Xamarin.Forms.Color and select Edit Color. Then you can use the color picker dialog to select a new color value:

Extract Attribute Value Into Property Binding

Professional Only

Configuration Id: com.mfractor.code_actions.xaml.extract_into_property_binding

Move a XAML value into your ViewModel and replace it with a data-binding using the Extract Attribute Value Into Property Binding refactoring.

When a Xaml attribute is initialised by a literal value (rather than an expression), this refactoring action allows a developer to extract that literal value as a property into the binding context and replace the attribute initialiser with a binding expression.

For example, given the attribute initialiser Text=\"Hello Xamarin.Forms!\", this refactoring would generate a user named property (EG: Message) in the binding context, initiliase it with the string literal \"Message\" and replace the attribute value with the binding expresion {Binding Message}.";

Uses:

Extract Resource Dictionary

Professional Only

Configuration Id: com.mfractor.code_actions.xaml.extract_resource_dictionary

You can use the Extract Resource Dictionary refactoring to move a resource dictionary into its own file.

Extracts the current resource dictionary into it's own XAML file with code behind.

Configurable Properties

Name Type Defaults To Description
DefaultXamlNamespace System.String resources What is the default name of the XAML namespace for the new control?
DefaultResourcesFolder System.String Resource Dictionaries What is the default folder that the new of the C# namespace for the new resource? If empty, the projects default namespace will be used.

Uses:

Extract XAML Into Control

Professional Only

Configuration Id: com.mfractor.code_actions.xaml.extract_xaml_into_control

Extracting a XAML container into a new control

Extracts a XAML layout container that derives from Xamarin.Forms.Layout into a new XAML control.

Configurable Properties

Name Type Defaults To Description
DefaultXamlNamespace System.String controls What is the default name of the XAML namespace for the new control?

Uses:

Fix Node Closing Tag And Children

Professional Only

Configuration Id: com.mfractor.code_actions.xaml.refactor.fix_node_closing_tag_and_childrem

When refactoring XAML, change an elements opening tag and then use MFractor to fix the names of the end tag and property setters.

Often when we are refactoring XAML code we will change the type of a XAML node. When we do this, we end up with the start and end tags being different. This code action let's you correct the end tag and property setters so that they match the opening tag.

Uses:

Migrate OnPlatform Usage

Professional Only

Configuration Id: com.mfractor.code_actions.xaml.migrate_on_platform_usage

Use the Migrate OnPlatform code action to convert OnPlatform declarations to the Xamarin.Forms 2.3.4 format.

In Xamarin.Forms 2.3.4, there were changes made to the OnPlatform class to enable greater platform-specifics flexibility in the future. These changes deprecated the OnPlatform.iOS, OnPlatform.Android and OnPlatform.WinPhone properties in favour of a generic On element to control the platform specifics.

The Migrate OnPlatform Usage code action is a refactoring that converts a pre-2.3.4 Xamarin.Forms OnPlatform usage to the new methodology using the nested On element.

For example, given the following OnPlatform:

<OnPlatform x:TypeArguments="Thickness" 
            Android="0, 0, 0, 0" 
            iOS="0, 20, 0, 0">
    <OnPlatform.WinPhone>
        0, 0, 0, 0
    </OnPlatform.WinPhone>
</OnPlatform>

MFractor would migrate the code to use the On element:

<OnPlatform x:TypeArguments="Thickness">
    <On Platform="Android">0, 0, 0, 0</On>
    <On Platform="iOS">0, 20, 0, 0</On>
    <On Platform="WinPhone">0, 0, 0, 0</On>
</OnPlatform>

Rename Xaml Namespace

Professional Only

Configuration Id: com.mfractor.code_actions.xaml.rename_xaml_namespace

Easily rename a XAML namespace by tapping Option+Return on a XAML namespace and choosing Rename Namespace.

The Rename Xaml Namespace code action will perform a symbolic rename-refactor on a particular Xaml within your document.

This is handy as you can then rename namespaces in a document without using a Find+Replace action; the rename xaml namespace action works against symbols so it will always rename only the namespace symbols.

To action this refactoring:

  • Within a Xaml document right click or Alt+Return on an xmlns attribute (EG: xmlns:local="clr-namespace:myApp")
  • Select Refactor.
  • Then Rename Namespace.
  • Enter a new namespace name when prompted and then click enter.

Your new namespace will be applied across the document:

Renaming a Xamarin.Forms Xaml namespace

Uses:

Replace String With Localisation Lookup

Professional Only

Configuration Id: com.mfractor.code_actions.xaml.replace_with_localisation_lookup

Need to localise your XAML? The Localisation Wizard moves string literals into RESX files and replaces that string with a localisation lookup!

This refactoring action will open the document localisation wizard, a dialog that walks through all strings in the current document and lets you easily replace them with a localised value lookup.

When localising XAML files, MFractor assumes you are adhering to the best practices as outlined in Localizing Xamarin.Forms Apps with RESX Resource Files.

Uses: