UWP Community Toolkit

UWP Community Toolkit

UwpToolkit1

Short introduction

Universal Windows Platform is developing and still new useful tools are being added to SDK to help developers achieve their needs. There are many great tools but today I would like to write about open-source UWP Community Toolkit.

What’s that?

UWP Community Toolkit is a new project that enables the developer community to collaborate and contribute new capabilities on top of the SDK. What are the benefits of this project?

  • Simplified app development
  • Open-source
  • Alignment with SDK – community feedback will be included in the future versions of Windows SDK

Let’s see what it offers.

What do I need to start?

1) Visual Studio 2015 Community (for free) or higher with update 3

2) Windows 10 SDK

 

Let’s start

1) Open Visual Studio and create new blank Universal App project:

UwpToolkit2

2) Open NuGet package manager and add “Microsoft.Toolkit.UWP”:

UwpToolkit3

3) To use UWP Toolkit you should add below code to each XAML Page and C# code:

<Page x:Class="MainPage"
 xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"...
using Microsoft.Toolkit.Uwp;

4) In MainPage.xaml.cs file add image (you can use any picture):

<Page
 x:Class="UwpToolkitSample.MainPage"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:local="using:UwpToolkitSample"
 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 mc:Ignorable="d"
 xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls">
  <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  <Image x:Name="image" HorizontalAlignment="Center" VerticalAlignment="Center" Source="Assets/windows10logo.png" Stretch="None"/>
  </Grid>
</Page>

Now we can use UWP Toolkit to apply blur on the image:

public sealed partial class MainPage : Page
 {
   public MainPage()
    {
     this.InitializeComponent();
    }

   protected async override void OnNavigatedTo(NavigationEventArgs e)
    {
     base.OnNavigatedTo(e);
     await image.Blur(10, 0, 10).StartAsync();
    }
 }

UwpToolkit4

Launch the app to see the result.

 

This is not the end. You can use UWP Toolkit to simplify contact with services like Facebook or Twitter:

Change your MainPage.xaml.cs file to look like below:

 public sealed partial class MainPage : Page
 {
   public MainPage()
    {
     this.InitializeComponent();
    }

   protected override void OnNavigatedTo(NavigationEventArgs e)
    {
     base.OnNavigatedTo(e);
     connectWithTwitter();
    }

   void connectWithTwitter()
    {
     // Initialize service
     TwitterService.Instance.Initialize(ConsumerKey.Text, ConsumerSecret.Text, CallbackUri.Text);

   // Login to Twitter
   if (!await TwitterService.Instance.LoginAsync())
    {
     System.Diagnostics.Debug.WriteLine("Cannot login...");
    }

   // Get current user info
   var user = await TwitterService.Instance.GetUserAsync();
   ProfileImage.DataContext = user;

   // Post a tweet
   await TwitterService.Instance.TweetStatusAsync(TweetText.Text);

   // Post a tweet with a picture
   await TwitterService.Instance.TweetStatusAsync(TweetText.Text, stream);

   // Search for a specific tag
   ListView.ItemsSource = await TwitterService.Instance.SearchAsync(TagText.Text, 50);
   }
 }

5) What features are currently included?

a) Animations – you can easily add visual effects Animations

b) Controls – custom controls Additional to SDK ready to use

c) Code helpers – classes that simplify common coding patterns like Color conversion, Internet connection detection

d) Notifications –  Live Tiles and Toast samples

e) Services – The toolkit show you how to connect to Bing, Facebook, and Twitter services

f) Open Source – Built as an open source project hosted on GitHub

6) Take a look at UWP Community Toolkit Sample App under the link below to test many different features:

UWP Toolkit Sample App

UwpToolkit5

 

Sum up

Really helpful, don’t you think? It is great because UWP Toolkit can be used to build apps for any Windows 10 device like Mobile, PC, HoloLens or Xbox. Currently you can use it with C# or Visual Basic.

If you would like to read more about this topic please refere to official documentation: UWP Toolkit Documentation

Have a nice coding! 🙂

 

Advertisements