XAML Refactoring

Autogenerated by MFractor v3.5.1

Edit Color Declaration

Professional Only

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

Extract Attribute Value Into Property Binding

Professional Only

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


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?
DefaultNamespace System.String What is the default name of the C# namespace for the new control? If empty, the projects default namespace will be used.


Migrate OnPlatform Usage

Professional Only

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

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">
        0, 0, 0, 0

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>

Example of using the Migrate OnPlatform usage XAML refactoring

Rename Xaml Namespace

Professional Only

Configuration Id: com.mfractor.code_actions.xaml.rename_xaml_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


Replace String With Localisation Lookup

Professional Only

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

Localising a XAML file using the localisation wizard

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.