Productivity Power Tools For Visual Studio Mac

The Productivity Power Tools is a collection of extensions that improve the developer experience with Visual Studio IDE. Though not officially supported, they provide a great way to try out new features that we’re experimenting with. You can read more about the origins of Productivity Power Tools. Search results for 'Productivity Power Tools', Visual Studio on marketplace.visualstudio.com. Xamarin Productivity and Platform Improvements for Visual Studio 2017. By Alessandro Del September 2018. Mobile app development with Xamarin and Visual Studio, both on Windows and on the Mac, is crucial for Microsoft, which has made large investments to improve the quality and power of its mobile development tools and platforms.

Productivity Power Tools 2015 for Visual Studio 2015

is an extension pack that brings powerful tools for improved developer productivity.

What's New - Hot-fix July 2016 [ Release Notes ]

  • Change default setting for Custom Document Well - Sort by Most Recently Used to OFF

What's New - July 2016 [ Release Notes ]

  • Major performance improvements for Solution Error Visualizer
  • Solution Explorer no longer ignores errors in files that have been filtered out by project scope in the Error List
  • New feature for Custom Document Well: Sort by Most Recently Used
    (Can be turned on in Tools->Options->Productivity Power Tools->Custom Document Well
    Setting: Sorting->Most recently used)

If you like Productivity Power Tools, we'd love to hear your views on which parts are most important to you in your day to day work. Please take a few minutes to fill out the survey online athttp://aka.ms/vspptsurvey

You can also Follow us on Facebook!

Also, try out these experimental DevLabs extensions:

[ Auto History andSnippetizer ]

Summary of features

  1. Peek Help
  2. Solution Error Visualizer
  3. Structure Visualizer
  4. Double click to maximize windows
  5. Timestamp margin
  6. Quick tasks – Edit Present On
  7. Ctrl + Click to Peek Definition / Go To Definition
  8. Recently Closed Documents
  9. Match Margin
  10. Power Commands context menu cleanup
  11. Syntactic Line Compression
  12. Quick Tasks
  13. Power Commands
  14. Middle-Click Scrolling
  15. Custom Document Well
  16. Tools Options Support
  17. HTML Copy
  18. Fix Mixed Tabs
  19. Align Assignments
  20. Column Guides

Changes since Productivity Power Tools 2013

This release contains all the features of the previousProductivity Power Tools 2013 with the following changes to work with Visual Studio 2015 RTM:

1. Solution Error Visualizer has been updated to take advantage of the new Visual Studio 2015 Error List and its advanced filtering capabilities; filters applied in the error list will now apply to the visualizer too.

2. Color Printing, Colorized Parameter Help andOrganize VB Imports are all incorporated into the Visual Studio 2015 core product (so they are no longer needed in Productivity Power Tools)

Release Notes

Build 14.0.24214.0

  • Eliminate UI delays caused by Solution Errors Visualizer extension
  • Improve Solution Error Visualizer extension integration with Visual Studio Error List
  • Custom Doc Well now sorts tabs by most recently used order by default (customizable via Tools/Options)
  • Fix an intermittent crash on moving document tab
  • Fixed 'Open Command Prompt' power command always opening VS2010 prompt if VS2010 is installed
  • CopyAsHTML improvements
  • Fix crash on editing Persian text

Detailed feature breakdown

Peek Help (Alt + F1)

We have introduced a feature called Peek Help that can be invoked from the context menu or using the keyboard shortcutAlt+F1. This brings up the F1 Help content inline in the editor, below the symbol, using Peek. This is a full browser control, so you can do navigation, find and so forth.

Solution Error Visualizer

Tools

This feature adds error, warning, and message squiggles to Solution Explorer. The information is fetched from the Error List and directly displayed in the Solution Explorer tree view. Hovering over the nodes with squiggles brings up a pop-up with the error/warning/message information.

Filtering

You can filter the Solution Explorer to just files with warnings/errors/messages using filter dropdown in the Solution Explorer toolbar. You can create a new Solution Explorer view, filter it down to Errors and use it as a dedicated Error window.

Note: Filtering the Error List by file scope (ie. Open Documents, Current Project, Current Document, etc) will not affect the display in the Solution Explorer.

Options

You can turn off categories of squiggles or the popup in Tools > Options Productivity Power Tools > Solution Error Visualizer.

Structure Visualizer

Structure Visualizer adds visual cues to syntactically signify blocks of code. The blocks allow you to quickly figure out the scope of a class, method and many other code scopes. Hovering over the block visual cues brings up a preview tooltip to help you visualize the scope you’re in

Scrollbar markers

The blocks are also marked on the Scrollbar with previews. As usual, you can turn this on/off through Tools Options > Productivity Power Tools > Other extensions > Show code structure in the margin.

Double-click to maximize windows

A quick, easy and temporary way to maximize any docked window by double-clicking its title bar and restoring/docking by double-clicking again.

Timestamp margin

Adds the timestamp information to the Output Window in Debug mode: (minutes. Seconds. Milliseconds)

You can customize the time format under Tools >Options > Productivity Power Tools > Other Extensions > Timestamp margin options

Quick Tasks - PresentEdit

By popular request, we have added the ability to customize the Font family and the Font size used by the PresentOn Quick task. To customize these settings, simply type “PresentEdit” in the Quick Launch search box to open a simple Xml file where you can specify the exact Font family and size.

Once you finish your customization, simply Save the file and you are done. Don’t worry about getting something wrong or making an error in this file. Any errors are automatically ignored and a new clean version of the file is created.

Ctrl + Click to Peek Definition

This feature enables clickable hyperlinks to symbols in source code in your code by holding down the Ctrl key when hovering with the mouse.

Ctrl + Click on any symbol to invoke Peek Definition on it.

This is the default behavior but if you want Ctrl + Click to Go To Definition, you can get that behavior by unchecking this option in Tools > Options > Productivity Power Tools > Other Extensions > Ctrl Click shows definitions in Peek.

Recently Closed Documents (Ctrl + Shift + Z)

Reopens a closed document, returning the cursor to its last position. Recently closed documents can be reopened through the Edit menu and clicking Undo Close or by using the Ctrl +Shift + Z shortcut.

You can view your recently closed documents by going to File > Recently Closed Documents menu.

Match Margin

This feature highlights all the textual matches of token at the caret location in the Editor.

Power Commands context menu cleanup

We have cleaned up the Solution Explorer context menu by moving some of the Power Command items into their own group. You still have all of the Power Commands intact, but we have just moved them into better locations within the Context Menu.

Syntactic Line Compression

Syntactic line compression enables you to make better use of your screen's vertical real-estate. It shrinks lines that contain neither letters nor numbers by 25% vertically, allowing more lines to be displayed in the editor. Other lines are not affected.

Quick Tasks

The Quick Launch Tasks extension provides easy access to commonly used options (EG: toggling line numbers) as well as popular functionality to VS (EG: collapsing/expanding regions). To activate Quick Tasks, access Quick Launch and write @tasks followed by one of the following options:

Option

Description

CollapseRegions

Collapses all #region tags in the current document

ExpandRegion

Expands all #region tags in the current document

TxtFont-

Decreases the text editor’s font size by 2 (min 6)

TxtFont0

Resets the text editor’s font size to the default 10

TxtFont+

Increases the text editor’s font size by 2 (max 60)

TxtFontReset

Resets all text editor font settings to their default values (based on current theme)

EnvFont-

Decreases the environment’s font size by 2 (min 5)

EnvFont0

Resets the environment’s font size to the default 9

EnvFont+

Increases the environment’s font size by 2 (max 59)

EnvFontReset

Resets all environment font settings to their default values (based on current theme)

InsTabsOff

Inserts spaces instead of a tab whenever a tab is inserted (all languages)

InsTabsOn

Keeps the tab that is inserted instead of inserting spaces (all languages)

LineNumOff

Turns off line numbers in the text editor (all languages)

LineNumOn

Turns on line numbers in the text editor (all languages)

PresentOff

Turns off presenter mode and returns the environment and text editor fonts to their pre-presentation values

PresentOn

Turns on presenter mode, which increases environment and text editor font sizes, and sets them to certain font families, so that VS is easier to see and read on a projector

PresentEdit

Allows you to customize the Font family and Font size used by the PresentOn extension

ResetToBasic

Resets VS to Visual Basic development settings

ResetToC++

Resets VS to Visual C++ development settings

ResetToC#

Resets VS to Visual C# development settings

ResetToF#

Resets VS to Visual F# development settings

ResetToGeneral

Resets VS to General development settings

ResetToJavaScript

Resets VS to JavaScript for Windows 8 Apps development settings

ResetToLightSwitch

Resets VS to LightSwitch development settings

ResetToSQL

Resets VS to SQL Server development settings

ResetToWeb

Resets VS to Web development settings

ResetToWebCode

Resets VS to Web (Code Only) development settings

SwitchCode

Switches between designer/code behind or header/source files, opening the file if

Necessary

TabSize-

Decreases the tab and indent size by 2 (all languages)

TabSize0

Resets the tab and indent size to the default 4 (all languages)

TabSize+

Increases the tab and indent size by 2 (all languages)

WordWrapOff

Turns off the text editor’s word wrap (all languages)

WordWrapOn

Turns on the text editor’s word wrap (all languages)


NOTE: The ResetTo… tasks are added based on the languages installed with Visual Studio

Power Commands

Productivity Power Tools For Visual Studio Mac

Power Commands is a set of useful extensions for the Visual Studio 2012 adding additional functionality to various areas of the IDE.
Individual power commands can be enabled or disabled from the Power Commands page in Tools -> Options in Visual Studio. It can be found under the Productivity Power Tools category. Most Power Commands are enabled by default. Below is a list of the commands included in Power Commands for Visual Studio 2012.
Format document on save
Enables formatting of tabs, spaces and other characters in a document to be saved. It is equivalent to using Format Document command under the Edit->Advanced menu. Disabled by default.

Remove and Sort Usings on save
Removes unused using statements and sorts the remaining using statements in the C# document being saved. Disabled by default.
Clear All Panes
Adds a button on the toolbar of the Output window that enables the user to clear all output panes at once.
Copy Path
Enables the file path of solutions, projects, folders and projects items to be copied from Solution Explorer via right-click menu.
Email CodeSnippet
Creates an email with the currently selected text. Available via right-click menu in the source code editor.
Insert Guid Attribute
Adds a Guid attribute to the selected class via right-click menu when the current selection is in class scope.
Show All Files
Shows the hidden files in all projects displayed in Solution Explorer when the solution node is selected. It enhances the Show All Files button, which would otherwise show the hidden files in the selected project node.
Collapse Projects
Collapses a project or projects in the Solution Explorer starting from the root selected node. This option resides in three different places on the Solution Explorer: Solution, Solution folders and Project nodes respectively.
Copy/Paste Class
Copies/Pastes a selected class entire content to/from the clipboard. When pasting a class, it is renamed to avoid a compilation error. It can be executed from a single project item or a project item with dependent sub items.
Copy/Paste References
Copies/Pastes one or more references to/from the clipboard. It can be executed from the references node, a single reference node or set of reference nodes.
Copy As Project Reference
Copies a project as a project reference to the clipboard. It can be executed from a project node.
Edit Project File
Opens the MSBuild project file for a selected project inside Visual Studio. It combines the existing Unload Project and Edit Project commands.
Open Containing Folder
Opens a Windows Explorer window pointing to the physical path of a selected item. It can be executed from a project item node.
Open Command Prompt
Opens a Visual Studio command prompt pointing to the physical path of a selected item. It can be executed from four different places: solution, project, folder and project item nodes respectively.
Unload Projects
Unloads all projects in a solution. This can be useful in MSBuild scenarios when multiple projects are being edited. This command can be executed from the solution node.
Reload Projects
Reloads all unloaded projects in a solution. It can be executed from the solution node.
Remove and Sort Usings
Removes and sort using statements for all classes given a project. It is useful, for example, in removing or organizing the using statements generated by a wizard. This command can be executed from a solution node or a single project node.
Extract Constant
Creates a constant definition statement for a selected text. Extracting a constant effectively names a literal value, which can improve readability. This command can be executed from the code editor by right-clicking selected text.
Clear Recent File List
Clears the Visual Studio recent file list. The Clear Recent File List command brings up a dialog that allows any or all recent files to be selected.
Clear Recent Project List
Clears the Visual Studio recent project list. The Clear Recent Project List command brings up a dialog that allows any or all recent projects to be selected.
Transform Templates
Executes a custom tool with associated text templates items. It can be executed from a DSL project node or a DSL folder node.
Close All
Closes all documents. It can be executed from a document tab.

Middle-Click Scrolling

Enables you can press down on your scroll wheel and the move the mouse to quickly scroll through your document!

Custom Document Well

This extension allows users to change the behavior of their document tabs. Users can customize the behavior and look of the tabs via the Tools > Options dialog.

  • Scrollable tabs
    Maintain spatial consistency of the documents that are included in the document well.
  • Vertical tabs
    Document tabs are shown vertically, allowing you to fit more tabs than are normally visible when shown horizontally.
  • Show close button in tab well
    Show the close document button in the document well that will close the active tab, similar to Visual Studio 2008.
  • Tab Behavior
    • More Commands for Navigation
      Using Ctrl+Alt+Page Down and Page Up to navigate between tabs (including pinned) in visual order.
      Activate a specific pinned tab by Ctrl+Num Pad 1 through 0
      Activate a specific regular tab by Ctrl+Alt+Num Pad 1 through 0
    • Sorting
      • Sort by most recently used
        Whenever a tab becomes active, it is moved to the left - such that all tabs will be sorted in most recently used order.
      • Sort tabs by project
        Tabs will be sorted by the project they belong to, thus keeping them always together in the document tab well.
      • Sort tabs alphabetically
        Tabs will be sorted alphabetically. When Sort By Project is turned on, tabs will be sorted first by project and then alphabetically.
  • Tab UI
    • Color tabs according to their project or according to regular expressions
      This option permits tabs to be colored according to the project they belong to. This is particularly useful when sorting tabs by project, as it allows you to immediately identify different groups of project documents.
      You can also configure regular expressions and assign a color to each one. If the name of a tab matches the configured regular expression, it will be colored with the assigned color.
  • Miscellenous options that modify the Tab UI
    • Show close button in tab
    • Modify dirty indicator style
      This option allows you to select from a set of different dirty indicators that you might prefer over the asterisk.
    • Modify minimum and maximum tab size
      Allows you to modify minimum and maximum tab size. Try setting minimum and maximum sizes to the same value, and you will have evenly spaced tabs.

Tools Options Support

As much as we try, some experiences in the Productivity Power Tools are not for everyone. If you want to shut off an extension, go to Tools | Options | Productivity Power Tools and find the extension on the right (remember to scroll!). By toggling the slider to Off and restarting Visual Studio, that extension will no longer be loaded and you will revert to the default Visual Studio behavior.

HTML Copy

Provides support for the HTML Clipboard format when cutting for copying code from the editor. This means there is no need to fix up the formatting of code when pasting it into a TFS work item form or another HTML based control. It is possible to modify the html format that gets copied to the clipboard. Users can customize the behavior in Tools > Options > Productivity Power Tools > HTML Copy.

HTML Copy improvements

We have introduced a new command Edit > Copy Html Markup that puts the raw HTML for the selection into the clipboard in plain text format, so that you can paste it into HTML editors that don’t support WYSIWYG or Paste Special.

We added two new options when copying: ReplaceTabsWithSpaces andUnindentToRemoveExtraLeadingWhitespace, which detects a common whitespace prefix and trims it so that the copied code is aligned with left margin wherever you paste it. For example, with all lines indented 12 spaces, this option will detect a common whitespace prefix of 12 spaces and trim that.

Fix Mixed Tabs

Warns users when a file opened or saved that contains a mixture of tabs & spaces. Adds an information bar to provide an easy way to fix the file if desired.

Align Assignments

Aligns assignment statements by typing Ctrl+Alt+]. For example, typing Ctrl-Alt-] when the following is selected:


Transforms it into this:


Note! This may conflict with your formatting settings. E.g. in C# you will need to disable: Tools->Options->Text Editor->C#->Formatting->Spacing->'Ignore spaces in declaration statements'

Column Guides

Draws a vertical line in the code editor to remind developers that their full line of code or comments may not fit one a single screen. Simply place the cursor at the appropriate column and select Add Guideline from the context menu

-->

September 2018

Volume 33 Number 9

[Xamarin Forms]

By Alessandro Del | September 2018

Mobile app development with Xamarin and Visual Studio, both on Windows and on the Mac, is crucial for Microsoft, which has made large investments to improve the quality and power of its mobile development tools and platforms. At the Build 2018 conference in May Microsoft unveiled a new generation of tools for cross-platform app development with C#, with a focus on productivity and performance. These include updates in the Xamarin tools for Visual Studio 2017, new features and improvements in Visual Studio for Mac, and the release of Xamarin.Forms 3.0.

In this article, I describe what’s new for mobile app developers working with C# and Xamarin in Visual Studio 2017, walking through the features and updates that solve issues that existed in previous versions. You need Visual Studio 2017 version 15.7.3 or newer to use the new features, but I recommend that you install the latest available version (15.7.4 at this writing). I’ll start with productivity updates and additions to Visual Studio 2017, and then I’ll describe what’s new in the platform support for iOS and Android.

Visual Studio 2017 Tools for Xamarin

The Visual Studio 2017 IDE has recently been improved with new and updated tools for Xamarin, including XAML editor updates, integrated tools for iOS and Android updates, enhanced platform support, and new versions of Xamarin.Forms. These improvements are extremely important and deserve a thorough discussion, so the first part of this article walks through features that are related to both the coding experience and the integrated platform support.

XAML Editor Updates Developers working with Xamarin.Forms will benefit from the new XAML code editor, which is now powered by the same engine that drives Windows Presentation Foundation (WFP) and Universal Windows Platform (UWP). This is extremely important for several reasons:

  • Full, rich IntelliSense support: Earlier versions of Intelli­Sense could make writing XAML markup painful to do. The new version adds linting, fuzzy matching and substring matching, which I’ll describe in more detail.
  • Enhanced support to binding expressions: IntelliSense now lists available objects for bindings based on the {Binding} markup extension and also lists available resources when using the {StaticResource} markup extension.
  • Quick actions and refactorings: Light bulb suggestions are now available to XAML in Xamarin.Forms, just as they have been for WPF and UWP, making it easy to resolve XML namespaces, remove unused namespaces, and organize code with contextualized suggestions.

The feature known as fuzzy matching provides an algorithm that helps you find appropriate completions based on what you typed. For example, if you type Stk and then press Tab, IntelliSense will add a StackLayout tag. Substring matching provides a list of possible completions as you type in a control name. For example, if you type Layout, IntelliSense will offer StackLayout, AbsoluteLayout and RelativeLayout as possible completions, as well as closing tags based on the same typing (see Figure 1). This feature is particularly useful when you only remember a control name partially.


Figure 1 Substring Matching in the XAML Editor for Xamarin.Forms

Visual Studio Tools For Application

Another interesting feature about string matching is CamelCase matching, which provides shortcuts based on CamelCase types. For instance, if you type RL and then press Tab, the editor inserts a RelativeLayout tag. With linting, the code editor immediately identifies some code issues, such as when a property has been specified more than once.

Many readers will know how useful features like light bulbs, quick actions and suggestions are, from their experience with both the C# code editor and the XAML code editor in WPF and UWP. Now these functions are available to Xamarin.Forms. For instance, if a code issue is detected, you can click the light bulb icon (or press Ctrl+.) and Visual Studio will show potential fixes, as you can see in Figure 2, where the code editor detects a missing XML namespace and suggests adding the proper namespace declaration.


Figure 2 The Light Bulb Provides In-Line Quick Actions for Code Issues

You can use the light bulb and quick actions to remove unused namespaces and sort namespaces, which helps keep your code cleaner. IntelliSense also has full support now for binding expressions with markup extensions. For example, if you had a PersonViewModel class you want to use as the binding context for your UI, and that’s declared as a local resource, IntelliSense will then help you create the binding expression by showing the list of available resources.

With a binding context set up, IntelliSense can help with creating binding expressions, by showing a list of properties exposed by the bound object. Figure 3 provides an example where you can also see a property called FullName, defined in the view model.


Figure 3 IntelliSense Makes It Easier to Create Binding Expressions

Beyond binding are improvements to popular existing features like Peek Definition and Go To Definition, which are now much more reliable in the Xamarin.Forms XAML editor. In fact, both features were problematic before the latest Visual Studio updates. Now you can quickly navigate to the definition of an object or resource defined in XAML or C# code, eliminating the chore of manually browsing your code. Peek Definition opens an interactive popup directly in the active editor window, while Go To Definition opens a separate editor window pointing to the desired resource.

Xamarin.iOS Remote Update The XAML editing experience isn’t the only area where Microsoft has worked to increase productivity. The tooling for Xamarin.iOS has also been enhanced.

Productivity Power Tools For Visual Studio Mac Python

As you know, building apps for iOS with Xamarin in Visual Studio 2017 requires that the same version of the Xamarin.iOS SDK be installed on both your Windows PC and Mac machine. If there was a version mismatch, Visual Studio reported a warning and you had to update your Mac manually. This is no longer necessary. Visual Studio 2017 now offers to install the latest version of the Xamarin.iOS SDK on the Mac on your behalf. You simply click Install in the Pair to Mac dialog box and wait for the update to complete.

Xamarin Tools for Automatic iOS Provisioning Creating apps for iOS requires some preliminary steps that can be really complicated. In addition to enrolling in Apple’s Developer Program, which is required to enable your Apple developer account to sign and publish apps to the App Store, you need to provision your iOS device. iOS provisioning will enable you to deploy and test your app on a device. iOS provisioning is usually done via Xcode on the Mac. Put succinctly, iOS provisioning requires you to:

  • Create a development team: This includes specifying the list of Apple developer accounts in the development team, enabling them to sign and publish an app.
  • Set up provisioning profiles: A provisioning profile is bundled into the compiled app package and contains three things: an app unique identifier (App ID), one or more development certificates required to test an app on physical devices, and a Unique Device Identifiers (UDI) list that enumerates devices allowed to run an app.
  • Create signing certificates: All apps must be signed before they can run on an iOS device, even for development, so a signing certificate is required. Different kinds of certificates are available to each developer account (such as development and publishing) depending on the level of subscription.

The Xamarin Team at Microsoft has created a useful document that explains how to get started with iOS provisioning (bit.ly/2NhzO0O), but the reality is that complexity is the biggest barrier for developers wanting to build apps for iOS. Fortunately, the latest releases of Visual Studio 2017 include support for automatic iOS provisioning. You simply provide your Apple developer account and Visual Studio 2017 will set up all the necessary artifacts on your behalf, through a connection to a Mac machine. To accomplish this, you must first associate your Apple ID to Visual Studio via Tools | Options | Xamarin | Apple Accounts. In the Options dialog, you’ll be able to associate one or more Apple IDs by clicking the Add button, after which Visual Studio 2017 shows the list of associated teams and the user role for each team.

Once you click OK, you can go to the iOS Bundle Signing tab of the Xamarin.iOS project properties and select the Automatic Provisioning option (see Figure 4).

Visual Studio Productivity Tools 2017


Figure 4 Enabling Automatic Provisioning

You’ll simply need to select the Team you wish to use for development from the Team dropdown and Visual Studio will generate the necessary provisioning profiles and signing certificates required to test apps on a physical device (which must be connected to the Mac machine).

Platform Support Improvements

The latest Xamarin releases include improvements that target several platforms, including Android, iOS, Tizen and macOS. In this article, I’ll explore platform improvements for iOS and Android, both of which share an updated project template wizard. When you create a new iOS or Android project, you’re prompted with a list of common templates (single view, master-detail, tabbed app and blank app). The project template wizard will also allow you to specify what kind of devices you want to support in your apps. Additionally, support for both platforms has been enhanced with specific improvements.

iOS Platform Support Xamarin.iOS has been refactored to include a fully static type system. As a result, iOS, macOS, tvOS and watchOS apps that you write with Xamarin are now between 30 percent and 50 percent smaller, because the linker is able to remove more code at build time. Memory usage has also decreased, especially at app startup. In addition, app startup is now much faster because most of the type registration is now done at build time rather than at runtime.

Android Platform Support Xamarin support for Android now includes a new tool called Android Device Manager, which ships with Visual Studio 2017 and makes it easier to create and maintain Android emulator images. You can launch the Android Device Manager via Tools | Android | Android Device Manager.

Not only can you create and edit emulator images, you can also quickly start an emulator instance via the Start button. This tool offers a large number of options that are out of the scope of this article, so refer to the documentation at bit.ly/2LhFUB1 for more information. Included in the recent update is the release of the Android Oreo SDK (API Level 27) and a feature known as Auto Install Android SDKs. If you open and build a project that requires a version of the Android SDK that you don’t have on your machine, a notification will appear to help you download the required version in the background. This feature is disabled by default, so you have to open Tools | Options | Xamarin | Android Settings and select Enable Auto Install Android SDKs.

It’s worth mentioning that Microsoft has also announced a preview of a Google Android emulator that runs on Hyper-V. This is a very important addition, because many developers used to work with the Visual Studio Android Emulator, which is based on Hyper-V and was recently discontinued by Microsoft. The new preview requires the Windows 10 April 2018 update with the Windows HyperVisor Platform installed and Visual Studio 2017 15.8 Preview 1 (or higher). Because the emulator is still in preview, I don’t cover it in this article, but you can read a very detailed and interesting blog post by Miguel de Icaza about it at bit.ly/2JsVrcq.

Xamarin.Forms Updates

Microsoft released Xamarin.Forms 3.0 at the Build 2018 conference in May, and more recently made Xamarin.Forms 3.1 available via NuGet. For developers building cross-platform apps with C#, the updates bring amazing new features and significant platform and UI improvements.

On the platform side, performance got a major boost in the form of improved fast renderers, which were introduced with version 2.5 last year. Renderers enable Xamarin.Forms to translate visual elements into native views—work that can get pretty expensive, especially with complex views. Microsoft redesigned the way renderers work in version 3.0 to boost rendering speed and performance.

Productivity Power Tools For Visual Studio Mac Free

On the UI side, Xamarin.Forms 3.0 introduces a new layout called FlexLayout. It works like a StackLayout, arranging child visual elements vertically or horizontally, while also being able to wrap the child visual elements if there’s not enough space in a single row or column. The following code snippet shows an example of how you can easily use a FlexLayout:

Productivity Power Tools For Visual Studio Macro

Productivity Power Tools For Visual Studio Mac

There are numerous FlexLayout properties, but the three most important are:

  • Wrap: A value from the FlexWrap enumeration that specifies if FlexLayout content should be wrapped to the next row if there’s not enough space in the first. Possible values are Wrap (wraps to the next row), NoWrap (keeps the view content on one row) and Reverse (wraps to the next row in the opposite direction).
  • Direction: A value from the FlexDirection enumeration that determines if the children of the FlexLayout should be arranged in a single row or column. The default value is Row, but other possible values are Column, RowReverse and ColumnReverse (where Reverse means that child views will be laid out in the reverse order).
  • JustifyContent: A value from the FlexJustify enumeration that specifies how child views should be arranged when there’s extra space around them. There are self-explanatory values such as Start, Center and End, as well as more granular options. These include SpaceAround, where elements are spaced with one unit of space at the beginning and end, and two units of space between them, so the elements and the space fill the line, and SpaceBetween, where child elements are spaced with equal space between units and no space at either end of the line, again so the elements and the space fill the line. The SpaceEvenly value causes child elements to be spaced so the same amount of space is set between each element as there is from the edges of the parent to the beginning and end elements.

Within child views, you can set the FlexLayout.AlignSelf attached property to specify how the view should be aligned inside the axis of the FlexLayout. This is an object of type FlexAlignItems and possible values are Auto, Start, Center, End and Stretch. The complete documentation for the FlexLayout control is available at bit.ly/2LaMzgt. Another interesting addition is support for Cascading Style Sheets (CSS), though it’s worth mentioning that CSS styles must be compliant to Xamarin.Forms to be consumed in mobile apps (see bit.ly/2miMcSO) and that not all CSS styles are supported. Therefore, this feature should be considered a complement to XAML styles, rather than a replacement. Also, CSS styles are parsed and evaluated at runtime, not at build time.

CSS styles in Xamarin.Forms can be declared and consumed in different ways. One option is within a StyleSheet tag to be added as a resource in a page, like in the following snippet:

The content of the CSS is enclosed in a CDATA section. For each visual element, you provide the desired property/value pairs. Another option is to consume an existing style from a .css file, as follows:

Remember that the .css file must be bundled with your application by setting its Build Action property as EmbeddedResource. CSS styles can also be declared and consumed in C# code. The following snippet shows how to declare and add a style to a page’s resources:

You could even load a .css file at runtime using the following snippet, where Page1 represents a page in the application and Project1 represents your project name:

Another extremely useful addition to Xamarin.Forms is the Visual State Manager (bit.ly/2NVH4AS), which you might already know if you have experience with WPF and UWP. With it, you can make changes to the UI you declared in XAML, based on a view’s state. For example, you can use the Visual State Manager to change the color of a view depending on its state, as shown in the code snippet in Figure 5.

Figure 5 Changing Background Color

With the markup in Figure 5, the Entry will automatically change its background color when its state changes. In this case, you need to set the Entry’s IsEnabled property as False to disable the view and trigger the Disabled state. States must be grouped into objects called VisualStateGroup. Each state is represented by the VisualState object, where you add Setter specifications as you would do with styles, therefore providing the name of the property you want to change and its value. Of course, you can specify multiple property setters.

Xamarin.Forms defines a set of states called common states, such as Normal, Focused and Disabled (see the VisualStateGroup with the CommonState name above); these states are common to each view. Other states might be available only to specific views and not to others. The Visual State Manager provides an elegant and clean way to control the UI behavior, all in your XAML code.

Xamarin.Forms 3.0 also makes it easy to implement right-to-left localization. The Device class now exposes the FlowDirection property, which reads this localization information from the device. You can then assign its value to the FlowDirection property of a view as follows:

Of course you can also bind the FlowDirection property of a view in XAML, making sure your view model exposes a property that returns the value of Device.FlowDirection. Just a few weeks after the release of Xamarin.Forms 3.0, Microsoft published version 3.1, which provides bug fixes and introduces many improvements to performance, reliability and visual elements. For instance, the SelectionMode property is now available in the ListView control, which can be used as follows:

Possible values are None and Single. This is an important improvement, because previous versions required that you manually write code to disable an item selection or create a custom renderer for the ListView. The Switch control also now supports specifying a different color when the selector is turned on, which you can do with the OnColor property of type Color, like so:

Before Xamarin.Forms 3.1, you had to write a custom renderer to get this result. Similarly, the Slider control allows specifying colors through the ThumbColor, MaximumTrackColor and MinimumTrackColor properties. Other additions are the IsSpellCheckEnabled property for Entry and Editor views, and the control over text-prediction and APIs that allow you to control the shadow over views in iOS.

The addition of bindable spans is worth taking a moment to explore, given this feature had been requested many times by the developer community. Put succinctly, the Span class, which you use for more sophisticated string formatting, now inherits from BindableObject, so that all the properties related to text formatting support data binding. A new bindable property called Style has been introduced, so you can use XAML styles defined in the app resources. The following XAML snippet provides an example:

You can find a full list of available additions in Xamarin.Forms 3.1 in the release notes page at bit.ly/2NkVA3T.

Wrapping Up

Xamarin is continuously advancing, not only to support evolving platforms and OSes, but to increase the quality and productivity of the development tools. In this article I’ve explored a huge number of new and updated features that solve many problems, from the code editor and integrated tools to platform and CSS support. More is yet to come as additional updates are released. It’s a good idea to regularly check the Xamarin blog (blog.xamarin.com) to stay up-to-date with the latest news and announcements.

Alessandro Del Solehas been a Microsoft MVP since 2008 and a Xamarin Certified Developer. He has authored many books, eBooks, instructional videos and articles about .NET development with Visual Studio. Del Sole works for Fresenius Medical Care as a senior software engineer, focusing on building .NET and mobile apps in the health care market. You can follow him on Twitter: @progalex.

Thanks to the following Microsoft technical experts who reviewed this article: David Britch, Amy Burns

Amy Burns is a Boston-based content developer at Microsoft. She has been a writer on the Xamarin documentation team since 2013, with a particular focus on Xamarin.iOS (and iOS provisioning) and Visual Studio for Mac.

Productivity Power Tools Visual Studio 2019

David Britch works in the Xamarin documentation team at Microsoft. He has written for a range of software development publications including books, guidance documentation, reference implementations, whitepapers, videos, and instructor-led training courses.