Tag Archives: nuget

Announcing UWP Community Toolkit 1.4

The UWP Community Toolkit is on its fourth release today. The previous version was packed with new controls, so we decided to focus on stabilizations and improvements on existing controls and services in version 1.4.

Among the improvements: better accessibility for all controls according to our contribution rules. Now every control can be used with keyboard, mouse and touch inputs. We also ensured that the controls provide enough information for Narrator to make them compatible with screen readers.

We also introduced a new project (and a new NuGet package) called Microsoft.Toolkit.Uwp.DeveloperTools. The goal of this project is to provide support tools for developers. For this first version of the project we started with two controls:

  • FocusTracker: Can be used in your application to display information about the current focused control (name, type, etc.). This is extremely useful when you want to ensure that your application is accessible.
  • AlignmentGrid: Can be used to display a grid, helping you align controls on your pages.

Developer tools are not meant to be deployed with your app, but rather used during development to help improve the overall quality of your app.

Along with the above improvements and stabilizations, we also added new features to this release. Here are a few of the main additions:

  1. Carousel: A new control that presents items in a list, where the selected item is always in the center and other items are flowing ­around it. This reacts not only to the content but also to layout changes, so it can adapt to different form factors automatically. The carousel can be horizontal or vertical.
  2. ViewExtensions: ApplicationViewExtensions, StatusBarExtensions & TitleBarExtensions provide a declarative way of setting AppView, StatusBar & TitleBar properties from XAML.
  3. NetworkHelper: Provides functionality to monitor changes in network connection, and allows users to query for network information without additional lookups.
  4. Saturation: Provides a behavior to selectively saturate a XAML element. We also introduced the CompositionBehaviorBase to ease creation of new composition-based behaviors (Blur now uses this).
  5. Twitter streaming API support: Twitter Service was missing support for Twitter’s streaming service; we added support for live tweets and events.
  6. Search box for Sample App: The new Sample App allows you to search for a sample directly from the main menu.

This is only a partial list of the changes in UWP Community Toolkit 1.4. For a complete overview of what’s new in version 1.4, please read our release note on GitHub.

You can get started by following this tutorial, or preview the latest features by installing the UWP Community Toolkit Sample App from the Windows Store.

As a reminder, the toolkit can be used in any app (across PC, Xbox One, mobile, HoloLens and Surface Hub devices) targeting Windows 10 November Update (10.0.10586) or above. The few features that rely on newer OS updates are clearly marked in the documentation and in the Sample App.

If you would like to contribute, please join us on GitHub!

Windows SDK for Google Analytics

Google Analytics is one of the most popular analytics libraries for websites and mobile apps. Google Analytics is widely used to track user sessions, screen views, events, crashes, social interactions and promotional campaigns on Android and iOS.

Today, we are excited to announce that Microsoft is launching a Windows SDK for Google Analytics, providing an easy way for Windows 10 developers to access these valuable services. The SDK can be integrated into your apps via a NuGet package. The source is hosted on GitHub.

There is a C# SDK that can be used both by Universal Windows Store apps and desktop apps, and there is also a C++ WinRT component for developers targeting UWP apps written in C++ or JavaScript.  Both the C# SDK and the C++ WinRT component use the same API names, so moving between them is seamless.

The SDK is built on top of Google’s Measurement Protocol, a service that allows developers to send engagement data to the Google Analytics Servers over HTTP requests. The APIs in the Windows SDK for Google Analytics are modeled on class names and design patterns from Google’s Android SDK, to ensure maximum portability and readability for those already familiar with Google Analytics on other platforms.

Getting started

If you prefer video format, this “Getting Started with the Windows SDK for Google Analytics” demonstrates every step below.

If you prefer written form, here is how you would add the Windows SDK for Google Analytics to your project:

The following are a few examples for a C# app. (If you prefer to see examples written for JavaScript or C++, the GitHub project includes additional samples in these languages.)

var tracker =  AnalyticsManager.Current.CreateTracker("EnterYourPropertyIdHere");
            AnalyticsManager.Current.ReportUncaughtExceptions = true;

            //create a timing event 
            var screenName = "MainPage";
            TimeSpan timeSpanToLoad = TimeSpan.FromMilliseconds(237); // sample:) 
            tracker.Send(HitBuilder.CreateTiming("load", screenName, timeSpanToLoad).Build());

            //Send a page view 
            tracker.ScreenName = screenName; 
            // Send a userclick event 
tracker.Send(HitBuilder.CreateEvent("user-events-category", "click", "sharing-button", 0).Build());

            // Send a social interaction 
            tracker.Send(HitBuilder.CreateSocialInteraction("facebook", "share", "link").Build());

Roadmap, feedback and contributions

We are excited about this feature-rich first release and the new capabilities it lights up for Windows developers. We welcome your suggestions for improvements as well as reports of any issues you find on our GitHub. Finally, remember that this is an open source initiative. We invite you to contribute your own code to make the SDK even better.

Windows Developer Day – Creators Update

Back in October, Satya, Terry and Panos introduced the Windows 10 Creators Update. They showed some of the new features and announced some amazing new additions to our Surface family of devices. Since then, my team has been working to complete the platform work for the Creators Update to deliver the full power of the Universal Windows Platform to our developers around the world.

Today, I had the chance to host the Windows Developer Day for the Creators Update and to share some of the developer-focused features that are coming soon. You can get started using these today by becoming a Windows Insider and downloading our latest preview SDK, which is now feature complete.

This is an exciting day for me because I love getting to spend time and share information with our developers. We are all driven by our mutual passion to build technology, whether we work on apps for enterprise, games or anything in between.

UWP Improvements

The Universal Windows Platform (UWP) enables your Windows apps to take advantage of the full power of the PC. To show an example of this power, I was joined on stage by Vincent Hardy from Adobe Systems, who showed us Adobe XD, a full-featured and sophisticated desktop application built on UWP.  The Adobe XD app combines beauty and power to deliver a great experience across multiple devices, form factors and input modalities.

We know that many developers want to take full advantage of modern Windows capabilities delivered in UWP, while still retaining their existing technology and code investments. The Desktop Bridge for Windows enables existing desktop applications to call UWP APIs and to be distributed and updated via the Windows Store. The Desktop Bridge makes it easier than ever to share code between Win32, .NET and UWP, taking advantage of the store’s ability to deliver easy and automated upgrades to help ensure that customers are always running the latest and best versions of their apps. Today, I showed Evernote, Photoscape X Pro and KODI, just three of the more than 330 Windows apps and games published to the store in the first four months of availability.

We believe we can work faster and smarter to deliver the best platform for developers if we work with the community. To do just this, I announced that we will make all Microsoft developer documents available and open for community collaboration. In addition, we will open our bug and feature backlog to the public and take bug contributions and feature requests starting today at noon.

In that spirit of openness, I was joined on stage by Todd Anglin from Progress, makers of the powerful Telerik controls. Telerik is popular with enterprise developers, enabling them to build great business applications with a rich set of easy-to-use UI controls. Todd showed us what these great controls can do, and announced that they are now Open Source and available on GitHub and also as NuGet packages. Find out more at telerik.com/uwp.

One of the great powers of UWP is its ability to run across a wide range of Windows devices and enable a wide range of experiences. Today, I showed a few examples of this ability:

  • Developers will be able to use the Windows Holographic Platform to bring amazing 3D experiences, both apps and games, not just to HoloLens, but to the wide range of mixed-reality headsets coming soon. We showed how easy it is to make a single app look fantastic across HoloLens and occluded headsets.
  • The new Cortana Skills Kit gives developers new and natural ways to connect user to their apps and services. We built a Cortana Skill on stage today and showed how easy it is to integrate bots created using the Microsoft Bot Framework and LUIS.
  • We know that your users interact with a variety of devices throughout the day, so we are building UWP capabilities (called “Project Rome”) to help your experiences flow seamlessly across devices, and guide users to your best and richest experience. Rome provides “apps for websites”, a simple tool that directs users to your apps (with the right context) rather than simply opening the browser. Rome’s cross-device services make it easy for users to continue an activity within your app as they move from one device to another, including Android devices. To make this possible, we released today the Rome SDK for Android.

Whenever I talk to developers, I hear that it is critically important for us to enable you to build apps that are visually beautiful and engaging, and that also take advantage of the latest and coolest hardware capabilities. It is also a high priority for us. Today, I showed some of the new capabilities that are coming to the visual and XAML layers of the platform that enable you to create beautiful user experiences through the use of effects, animations and transitions. With only a small amount of code, you can bring these effects to your apps with amazing results that delight users. In the Creators Update, we have worked to deliver new capabilities in pen and ink, including a more powerful ink toolbar that’s easy for any developer to use; smart ink, which enables recognition of lists, simple shapes and even math symbols; and enhanced APIs that enable you to do more than ever with the Surface Dial. Check out the video of the presentation for a full demo that shows a lot of these features coming together to make a beautiful and engaging app.

Games on UWP

I talked a lot about apps, but we’re also building UWP to be the best platform for building amazing games that run across the PC and Xbox One. With the Creators Update, UWP makes game development faster, easier and better. Specifically, I’d like to call out three key UWP improvements that will be appreciated by gamers and devs alike:

  • Game Mode: Windows 10 can optimize system resources to deliver the best PC gaming experience possible.
  • UWP on Xbox: UWP games (along with apps) will now be available on Xbox One via the Windows Store.
  • Windows Sonic: Microsoft’s next-gen spatial audio platform provides a powerful, immersive sound experience with support for Dolby Atmos. Windows Sonic will be available on Xbox One and Windows 10 PCs, also supporting both speakers and headphones.
  • Intelligent install: Lastly, the UWP packaging format makes it easier to install the bits in the right order, letting players jump into a new game (or app) before it has fully downloaded. And updates focus on downloading only the bits that have changed, so players can jump back in even faster.

For more information on these features and many more coming this year, tune into the Xbox sessions at GDC in a few weeks.

Windows is the home for all developers

I’m a developer, and my team is a team of developers. Like you, we love our tools and services and we’re very demanding of them. We want Windows to be the very best place to develop experiences, whether for Windows, the web or cross-platform. Today, we showed some of the performance, stability and debugging improvements in Visual Studio 2017. We demonstrated improvements to the Console and Bash, as well as to the Windows Subsystem for Linux. We showed remote access to device information via the Windows Device Portal, and even pixel-level GPU debugging with the new PIX tool for Windows.

The Windows Store team walked through several new and improved services coming in the next few months. Store Services APIs provide services to help you understand how your app is performing in the wild, including analytics and telemetry, flighting, automated submissions and updates, and ad campaigns.  The team also highlighted updated services to enable better user engagement using A/B testing, targeted push notifications and more.

And, of course, I recognize that you use lots of services from providers other than Microsoft, so today it gave me great pleasure to show powerful additions to the collection of middleware that is available to Windows Developers. Today, we announced the immediate availability to two important libraries:

  • The Windows SDK for Google Analytics brings one of the most popular and powerful real-time analytics packages to Windows. The core library works with UWP, Xamarin, Windows Forms and WPF, allowing for maximum code reuse.
  • Facebook App Install Ads are now available for UWP apps. Facebook App Install Ads are displayed in the Facebook newsfeed both on the web and in the Facebook app, bringing immense reach to Windows developers, as well as rich targeting capabilities (including interests, location and demographics) and their ads manager dashboard.

Where to get the bits

Here’s a quick recap of some of the announcements we made today:

  • Windows SDK Availability: Become a Windows Insider and get the newest feature-complete flight of the Windows 10 Creators Update SDK today.
  • Documentation: For the first time, all of Microsoft’s developer documentation will be in one place (http://docs.microsoft.com/) where it will be easier to find and use. We are also opening up the docs to community contribution.
  • Developer Platform Backlog: My team and I are making our backlog public, for both features and bugs. This will be online at noon today at https://developer.microsoft.com/windows/platform.
  • Telerik Controls: The Telerik UWP control library is now open source and available on GitHub and as NuGet packages. Find out more at telerik.com/uwp.
  • Cortana Skills Kit: The Cortana Skills Kit will enter open Developer Preview later this month.
  • Rome SDK for Android: This is a new SDK that brings the cross-devices services of “Project Rome” to Android devices, allowing easy and powerful integration with Windows. Find the new SDK at https://github.com/Microsoft/project-rome.
  • UWP Community Toolkit 1.3: Today, we are releasing a big update to the toolkit that includes many contributions from our developer community.
  • Windows SDK for Google Analytics: This new SDK, available now, enables Windows developers (UMP, Xamarin, WPF and WinForms) access to one of the more popular and powerful real-time analytics suites. Get this today at https://github.com/dotnet/windows-sdk-for-google-analytics.
  • Windows SDK for Facebook: With one billion users, Facebook offers one of the most powerful tools for you to acquire new users for your app or game. Check out the new SDK here: https://developers.facebook.com/docs/app-ads/windows-sdk.

It was a great day today, and there is more to come. We look forward to seeing you at Build in a few months when we will go deeper into the Creators Update capabilities for developers, and take a look at what’s coming next. In the meantime, I’d like to invite all of you to get started developing for Windows Creators Update today. Download the SDK, update your applications with new features (or build all-new apps that deliver the best new experiences), and please keep giving us feedback.

— Kevin

Using SQLite databases in UWP apps

For many developers, SQLite has become the preferred client-side technology for data storage. It is a server-less, embedded, open-source database engine that satisfies most local data access scenarios. There are numerous advantages that come with its use, many of which are explained in the SQLite about page.

Since the Windows 10 Anniversary Update (Build 14393), SQLite has also shipped as part of the Windows SDK. This means that when you are building your Universal Windows Platform (UWP) app that runs across the different Windows device form factors, you can take advantage of the SDK version of SQLite for local data storage. This comes with some advantages:

  • Your application size reduces since you don’t download your own SQLite binary and package it as part of your application
    • Note: Microsoft.Data.SQLite (used in the example below) currently has an issue where both SQLite3.dll and WinSQLite.dll are loaded in memory whenever a .NET Native version of your application is run. This is a tracked issue that will be addressed in subsequent updates of the library.
  • You can depend on the Windows team to update the version of SQLite running on the operating system with every release of Windows.
  • Application load time has the potential to be faster since the SDK version of SQLite will likely already be loaded in memory.

Below, we provided a quick coding example on how to consume the SDK version of SQLite in your C# application.

Note: Since the Windows SDK version of SQLite has only been available since the Windows 10 Anniversary Update, it can only be used for UWP apps targeting Build 14393 or higher.

C# Example

In this example, we will build a UWP application that will allow users to input text into an app local database. The goal is to provide developers with concise guidance on how to use the SQLite binary that’s shipped as part of the Windows SDK. Therefore this code sample is meant to be as simple as possible, so as to provide a foundation that can be further built upon.

An example of the end product is shown below:

SQLite C# API Wrappers

As mentioned in the SQLite documentation, the API provided by SQLite is fairly low-level and can add an additional level of complexity for the developer. Because of this, many open-source libraries have been produced to act as wrappers around the core SQLite API. These libraries abstract away a lot of the core details behind SQLite, allowing developers to more directly deal with executing SQL statements and parsing the results.

For SQLite consumption across Windows, we recommend the open-source Microsoft.Data.Sqlite library built by the ASP.NET team. It is actively being maintained and provides an intuitive wrapper around the SQLite API. The rest of the example assumes use of the Microsoft.Data.Sqlite library.

Alternative SQLite wrappers are also linked in the “Additional Resources” section below.

Visual Studio set-up

The packages used in this sample have a dependency on NuGet version 3.5 or greater. You can check your version of NuGet by going to HelpAbout Microsoft Visual Studio and looking through the Installed Products for NuGet Package Manager. You can go to the NuGet download page and grab the version 3.5 VSIX update if you have a lower version.

Note: Visual Studio 2015 Update 3 is pre-installed with NuGet version 3.4, and will likely require an upgrade. Visual Studio 2017 RC is installed with NuGet version 4.0, which works fine for this sample.

Adding Microsoft.Data.Sqlite and upgrading the .NET Core template

The Microsoft.Data.Sqlite package relies on at least the 5.2.2 version of .NET Core for UWP, so we’ll begin by upgrading this:

  • Right click on ReferencesManage NuGet Packages
  • Under the Installed tab, look for the Microsoft.NETCore.UniversalWindowsPlatform package and check the version number on the right-hand side. If it’s not up to date, you’ll be able to update to version 5.2.2 or higher.

Note: Version 5.2.2 is the default for VS 2017 RC. Therefore, this step is not required if you are using this newest version of Visual Studio.

To add the Microsoft.Data.Sqlite NuGet package to your application, follow a similar pattern:

  • Right-click on ReferencesManage NuGet Packages
  • Under the Browse tab, search for the Microsoft.Data.Sqlite package and install it.


Application User Interface

We’ll start off by making a simple UI for our application so we can see how to add and retrieve entries from our SQLite database.

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <TextBox Name="Input_Box"></TextBox>
        <Button Click="Add_Text">Add</Button>
        <ListView Name="Output">
                    <TextBlock Text="{Binding}"/>

There are three important parts to our application’s interface:

  1. A text box that allows us to take text from the user.
  2. A button linked to an event for pulling the text and placing it in the SQLite database.
  3. An ItemTemplate to show previous entries in the database.

Code Behind for Application

In the App.xaml.cs and MainPage.xaml.cs files generated by Visual Studio, we’ll start by importing the Microsoft.Data.Sqlite namespaces that we’ll be using.

using Microsoft.Data.Sqlite;
using Microsoft.Data.Sqlite.Internal;

Then as part of the app constructor, we’ll run a “CREATE TABLE IF NOT EXISTS” command to guarantee that the SQLite .db file and table are created the first time the application is launched.

public App()
    this.Suspending += OnSuspending;
    SqliteEngine.UseWinSqlite3(); //Configuring library to use SDK version of SQLite
    using (SqliteConnection db = new SqliteConnection("Filename=sqliteSample.db"))
        String tableCommand = "CREATE TABLE IF NOT EXISTS MyTable (Primary_Key INTEGER PRIMARY KEY AUTOINCREMENT, Text_Entry NVARCHAR(2048) NULL)";
        SqliteCommand createTable = new SqliteCommand(tableCommand, db);
        catch (SqliteException e)
            //Do nothing

There are couple of points worth noting with this code:

  1. We make a call to SqliteEngine.UseWinSqlite3() before making any other SQL calls, which guarantees that the Microsoft.Data.Sqlite framework will use the SDK version of SQLite as opposed to a local version.
  2. We then open a connection to a SQLite .db file. The name of the file passed as a String is your choice, but should be consistent across all SqliteConnection objects. This file is created on the fly the first time it’s called, and is stored in the application’s local data store.
  3. After establishing the connection to the database, we instantiate a SqliteCommand object passing in a String representing the specific command and the SqliteConnection instance, and call execute.
  4. We place the ExecuteReader() call inside a try-catch block. This is because SQLite will always throw a SqliteException whenever it can’t execute the SQL command. Not getting the error confirms that the command went through correctly.

Next, we’ll add code in the View’s code-behind file to handle the button-clicked event. This will take text from the text box and put it into our SQLite database.

private void Add_Text(object sender, RoutedEventArgs e)
    using (SqliteConnection db = new SqliteConnection("Filename=sqliteSample.db"))

        SqliteCommand insertCommand = new SqliteCommand();
        insertCommand.Connection = db;
        //Use parameterized query to prevent SQL injection attacks
        insertCommand.CommandText = "INSERT INTO MyTable VALUES (NULL, @Entry);";
        insertCommand.Parameters.AddWithValue("@Entry", Input_Box.Text);        

        catch (SqliteException error)
            //Handle error
    Output.ItemsSource = Grab_Entries();

As you can see, this isn’t drastically different than the SQLite code explained in the app’s constructor above. The only major deviation is the use of parameters in the query so as to prevent SQL injection attacks. You will find that commands that make changes to the database (i.e. creating tables, or inserting entries) will mostly follow the same logic.

Finally, we go to the implementation of the Grab_Entries() method, where we grab all the entries from the Text_Entry column and fill in the XAML template with this information.

private List<String> Grab_Entries()
    List<String> entries = new List<string>();
    using (SqliteConnection db = new SqliteConnection("Filename=sqliteSample.db"))
        SqliteCommand selectCommand = new SqliteCommand("SELECT Text_Entry from MyTable", db);
        SqliteDataReader query;
            query = selectCommand.ExecuteReader();
        catch(SqliteException error)
            //Handle error
            return entries;
    return entries;

Here, we take advantage of the SqliteDataReader object returned from the ExecuteReader() method to run through the results and add them to the List we eventually return. There are two methods worth pointing out:

  1. The Read() method advances through the rows returned back from the executed SQLite command, and returns a boolean based on whether you’ve reached the end of the query or not (True if there are more rows left, and False if you’ve reached the end).
  2. The GetString() method returns the value of the specified column as a String. It takes in one parameter, an int that represents the zero-based column ordinal. There are similar methods like GetDataTime() and GetBoolean() that you can use based on the data type of the column that you are dealing with.
    1. The ordinal parameter isn’t as relevant in this example since we are selecting all the entries in a single column. However, in the case where multiple columns are part of the query, the ordinal represents the column you are pulling from. So if we selected both Primary_Key and Text_Entry, then GetString(0) would return the value of Primary_Key String and GetString(1) would return the value of Text_Entry as a String.

And that’s it! You can now build your application and add any text you like into your SQLite database. You can even close and open your application to see that the data persists.

A link to the full code can be found at: https://github.com/Microsoft/windows-developer-blog-samples/tree/master/Samples/SQLiteSample

Moving Forward

There are plenty of additions that you can make to tailor this sample to your needs:

  • Adding more tables and more complicated queries.
  • Providing more sanitation over the text entries to prevent faulty user input.
  • Communicating with your database in the cloud to propagate information across devices.
  • And so much more!

What about Entity Framework?

For those developers looking to abstract away particular database details, Microsoft’s Entity Framework provides a great model that lets you work at the “Object” layer as opposed to the database access layer. You can create models for your database using code, or visually define your model in the EF designer. Then Entity Framework makes it super-easy to generate a database from your defined object model. It’s also possible to map your models to existing databases you may have already created.

SQLite is one of many database back-ends that Entity Framework is configured to work with. This documentation provides an example to work from.


From embedded applications for Windows 10 IoT Core to a cache for enterprise relations database server (RDBS) data, SQLite is the premier choice for any application that needs local storage support. SQLite’s server-less and self-contained architecture makes it compact and easy to manage, while its tried and tested API surface coupled with its massive community support provides additional ease of use. And since it ships as part of Windows 10, you can have peace of mind, knowing that you’re always using an up-to-date version of the binary.

As always, please leave any questions in the comments section, and we’ll try our best to answer them. Additional resources are also linked below.

Additional Resources

Announcing “UWPDesktop” NuGet Package Version 14393

The UWPDesktop NuGet package is here to improve the developer experience with Visual Studio when walking along the Desktop Bridge.

The Desktop Bridge allows you to call UWP APIs directly from your WinForms, WPF or VB application. You can use APIs such as Live tiles, notifications, App Services and many more!

Previously, calling UWP APIs from a converted app was a confusing process. You had to find and reference the right .dll or .winmd, and it often wasn’t obvious which one to choose.

For example, to use “await” on UWP types, you had to reference the System.Runtime.WindowsRuntime.dll (c:Program Files (x86)Reference AssembliesMicrosoftFramework.NETCorev4.5
System.Runtime.WindowsRuntime.dll), which was actually from Windows 8.1 and therefore only worked in conjunction with “facadewindows.winmd” (c:Program Files (x86)Windows Kits10UnionMetadataFacadeWindows.WinMD).

AppServiceConnectionStatus status = await connection.OpenAsync();

Confusing, right? The new way is much simpler – just include the latest UWPDesktop NuGet package to your project, and you’re ready to call any supported UWP API without needing additional references.

You have two options for installing the package:

  1. In Visual Studio, right-click on your project, select “Manage NuGet Packages,” and search for and install the UWPDesktop package (as shown in the screenshot below):

  2. Use the Package Manager Console

Install-Package UwpDesktop

Warnings for unsupported UWP APIs

Not all modern APIs can be called directly from your desktop application; for example, you still can’t use XAML or SecondaryTile in your WinForms app. The UWPDesktop NuGet package makes your life easier by raising a warning if you try and call an unsupported API.

For more information and to learn more about the UWPDesktop NuGet package and Desktop Bridge, check out the resources below.


XAML Behaviors, open source and on UWP

Your requests to grow the XAML Behaviors platform and bring them forward to support UWP app development have been heard. Today we announce the next step: XAML Behaviors natively supported for UWP and shipping as a NuGet package (for both native and managed projects). Additionally, to build a vibrant community around the platform, Behaviors are open source and on GitHub. Now, you can help influence the future direction of Behaviors.

The History of Behaviors

Originally released for WPF and Silverlight, and based on the concept of EventTriggers in WPF, designers and developers used Behaviors as an easy means for rapidly building their apps while promoting code reuse. Behaviors encapsulate reusable functionality for elements which could be easily added to XAML without the need for more imperative code.

WIth Visual Studio 2013, Behaviors were brought forward for use in Windows 8.1 Store apps (as Extension SDKs). Now, with the Universal Windows Platform, we will ship Behaviors as a NuGet package.

What are Behaviors and Actions?

Using both Behaviors and Actions, developers can create a wide variety of interactive scenarios.

Behaviors are attached to a control or element and listen for something to happen. What that “something” is can vary from an event firing (like a mouse click) or some data changing (as when a slider is moved to change a value). When the event the Behavior was listening for happens, it triggers one or more Actions.

Actions are invoked by Behaviors and execute on a selected element or control. Some examples of Actions can range from calling a method, navigating to another page, or triggering a storyboard.

Behaviors can be seen as event listeners and handlers. The following markup listens for a button to be clicked in order to play a storyboard:

<Button x:Name="button">
      <Core:EventTriggerBehavior EventName="Click">
         <Media:ControlStoryboardAction Storyboard="storyboard1"/>

Why are we open sourcing?

From adoption in popular frameworks to demand on UserVoice, it is clear that you want Behaviors to be bigger. It’s exactly because of this excitement that we want to open source Behaviors. Releasing as a NuGet package and hosting all Behaviors code on GitHub will allow new features and fixes to be addressed more quickly. When a new Behavior or feature is added to the repo, it can be consumed and used almost immediately. Opening up to contributions lets the Behaviors platform grow by empowering the community to set the pace and direction.

Open source model

Here’s our plan to build a vibrant community around Behaviors and open up the code.:

  1. Release cadence

    Behaviors will be released as an updated NuGet Package every quarter, provided there are meaningful changes. By releasing a stable version every three months, new contributions will constantly be taken into the GitHub repo and will build up the catalog of Behaviors for developers to use.

  2. Contribution model

    A committee of Microsoft Most Valuable Professionals (MVP) leaders will evaluate contributions to maintain quality and direction of the project. This project committee will approve and comment on submitted pull requests from the community.

    As the open source project grows and more contributors are committed to Behaviors, we plan to restructure the project to give authority to contributors who add the most value to the project. Whether it be through code, documentation, or other means of improving Behaviors, the goal is to give the community more control over Behaviors and empower users to build and add the features they most want to see.

  3. Integration into Blend

    In moving away from the Extension SDK approach, some changes have been made to the way Behaviors are presented in Blend for Visual Studio. These changes are reflected in Update 1 RTM release. Before, Behaviors were presented as a pre-populated list in the Assets Pane. Now, the Assets Pane prompts users with a link to install the NuGet Package. Clicking this link will download and reference the latest NuGet Package and will populate the list with all the latest and greatest Behaviors.

    You will also be able to get the latest version of Behaviors in both Visual Studio and Blend using the NuGet Package Manager.

    To install via the NuGet Package Console, run the following command for managed projects:

    PM> Install-Package Microsoft.Xaml.Behaviors.Uwp.Managed

    For native:

    PM> Install-Package Microsoft.Xaml.Behaviors.Uwp.Native

Philosophy and direction

Behaviors will evolve as developers contribute to the project. However, not all pull requests will be accepted and merged into the repo. Here are the four philosophy and goals for Behaviors that we hope will help guide the types of contributions we receive.

  1. Targeting common interactive scenarios

    Behaviors should be a toolkit that target a wide audience of developers and empowers them to be more productive. The Behaviors taken into the project should address common and core user scenarios that many will find value in. To ensure that developers get the most out of what is published, Behaviors that address uncommon or limited scenarios may not be accepted into the core package. However, shipping these Behaviors in other NuGet packages that express a dependency on the core Behaviors NuGet package is encouraged. The project committee is actively looking into solutions for this and will guide the project accordingly.

  2. Writing good documentation and samples

    The Behaviors GitHub page, documentation, and sample apps should be good sources to teach new developers about Behaviors, and how to use them. Whether a user is new to building apps and using Behaviors, or experienced and looking to create their own custom Behaviors, the proper resources to do whatever a developer needs and wants to do should be provided.

  3. Concentrating on the SDK and not on the tooling

    Rather than concentrating on new tooling and the authoring experience behind Behaviors, building out the platform should be the goal. Behaviors are a toolkit for developers to leverage in their apps, instead of new value editors for Blend or Visual Studio.

  4. Co-evolving C++ Behaviors evolve instep

    Behaviors support both native and managed projects. While expecting more development and contributions on the C# side, there should still be adequate C++ support. If a Behavior does not utilize reflection, considerations should be made to add a C++ version to make sure no language gets left behind.

What can I do?

Start using Behaviors now. If you previously referenced the Behaviors Extension SDK, please download and install the NuGet package and reference that. The NuGet package ships with the exact same namespace and API as the original Extension SDK in most cases, so switching over is easy. While the Extension SDK will still be supported, further development will only be pursued in the NuGet version.

Additionally, with the release of the NuGet package, some partnering frameworks are simultaneously shipping updates that support the new Behaviors package: Caliburn.Micro and Cimbalino Toolkit now leverage the new Behaviors. Check them out!


The XAML Behaviors that you know and love from building 8.1 apps are now ready for UWP, open source, and shipped as a NuGet package. Contributions of new and useful Behaviors are always welcome and encouraged.

I’d like to extend a big thank you to our MVP leaders for dedicating their time and effort to this cause and helping to guide this project as Behaviors are opened to the community.

Visit the GitHub page to learn more. If you have feedback, suggestions, or comments we’d love to hear them! Tweet using #BehaviorsGoOpenSource. Share what where you’d like Behaviors to go by submitting issues on the GitHub page or email.

This blog post was written by Jon Chu, a Program Manager on Visual Studio and .NET