Windows 10 – Universal Windows Platform – Tailored App

Step 1

Download Visual Studio Community 2015 and install it onto your computer, if it’s already downloaded and installed select Launch to start Visual Studio Community 2015 or if it has already been downloaded and installed then start the application you may also need to Enable your device for development.

2015-visual-studio

Step 2

Once Visual Studio Community 2015 has started select File, then New, then Project… from the Menu.

2015-file-new-project

Step 3

From the New Project window select Visual C# from Installed, Templates then select Blank App (Windows Universal) from the list, then type in a Name and select a Location to save to before selecting Ok to create the Project.

2015-new-project

Step 4

Once done select from the Menu, Project, then Add New Item…

2015-project-add-new-item

Step 5

From the Add New Item window select Visual C# from Installed and select Code then select Code File from the list, then type in the Name as Library.cs before selecting Add to add the file to the Project

2015-add-new-item-library

Step 6

Once in the Code View for Library.cs the following should be entered:

using System;
using System.Collections.Generic;
using Windows.System;
using Windows.UI.Xaml.Controls;

public class Setting
{
    public string Name { get; set; }
    public string Icon { get; set; }
    public string Value { get; set; }
}

public class Library
{
    public List<Setting> Settings
    {
        get
        {
            return new List<Setting>() {
            new Setting() { Name = "Display", Icon = "\uE7F8", Value = "display" },
            new Setting() { Name = "Notifications", Icon = "\uE91C", Value = "notifications" },
            new Setting() { Name = "Battery", Icon = "\uE8BE", Value = "batterysaver" },
            new Setting() { Name = "Storage", Icon = "\uE8B7", Value = "storagesense" },
            new Setting() { Name = "Data", Icon = "\uE774", Value = "datausage" },
            new Setting() { Name = "Personalisation", Icon = "\uE771", Value = "personalization" },
            new Setting() { Name = "Privacy", Icon = "\uE1F6", Value = "privacy" },
            new Setting() { Name = "Developers", Icon = "\uEC7A", Value = "developers" }
            };
        }
    }

    public static async void Launch(GridView grid)
    {
        string value = ((Setting)(grid.SelectedItem)).Value;
        await Launcher.LaunchUriAsync(new Uri("ms-settings:" + value));
    }
}

It should then appear as such:

2015-tailored-app-library

Step 7

From the Solution Explorer select App.xaml

2015-app-library

Step 8

Select from the Menu, View then Designer

2015-view-designer

Step 9

The XAML View will be displayed and in this above </Application> enter the following XAML:

<Application.Resources>
	<DataTemplate x:Key="Desktop">
		<Grid Width="200" Height="200">
			<StackPanel VerticalAlignment="Center">
				<Viewbox Height="50" Width="50" HorizontalAlignment="Center">
					<TextBlock Text="{Binding Icon}" FontFamily="Segoe MDL2 Assets" 
						Foreground="{ThemeResource SystemControlHighlightAccentBrush}"/>
				</Viewbox>
				<TextBlock Text="{Binding Name}" Margin="10" HorizontalAlignment="Center" 
					Style="{StaticResource FlyoutPickerTitleTextBlockStyle}"/>
			</StackPanel>
		</Grid>
	</DataTemplate>
	<ItemsPanelTemplate x:Key="DesktopItems">
		<ItemsWrapGrid Orientation="Horizontal" MaximumRowsOrColumns="4"/>
	</ItemsPanelTemplate>
	<DataTemplate x:Key="Mobile">
		<Grid Width="200">
			<StackPanel Orientation="Horizontal">
				<Viewbox Height="25" Width="25" HorizontalAlignment="Left">
					<TextBlock Text="{Binding Icon}" FontFamily="Segoe MDL2 Assets" 
						Foreground="{ThemeResource SystemControlHighlightAccentBrush}"/>
				</Viewbox>
				<TextBlock Text="{Binding Name}" Margin="10" HorizontalAlignment="Left" 
					Style="{StaticResource BodyTextBlockStyle}"/>
			</StackPanel>
		</Grid>
	</DataTemplate>
	<ItemsPanelTemplate x:Key="MobileItems">
		<ItemsWrapGrid Orientation="Horizontal" MaximumRowsOrColumns="1"/>
	</ItemsPanelTemplate>
</Application.Resources>

It should appear as such:

2015-tailored-app-app-xaml

Step 10

Once done select from the Menu, Project, then Add New Item…

2015-project-add-new-item

Step 11

From the Add New Item window select Visual C# from Installed and select XAML then select Blank Page from the list, then type in the Name as SecondaryPage.xaml before selecting Add to add the file to the Project

2015-add-new-item-page

Step 12

The Design View will be displayed along with the XAML View and in this below <Grid Background=”{ThemeResource ApplicationPageBackgroundThemeBrush}”> enter the following XAML:

<GridView Name="Display" HorizontalAlignment="Center" VerticalAlignment="Center"  
	SelectionChanged="Display_SelectionChanged" 
	ItemTemplate="{StaticResource Mobile}" 
	ItemsPanel="{StaticResource MobileItems}"
	ItemsSource="{x:Bind Path=Library.Settings}"/>

It should appear as such:

2015-tailored-app-page-xaml

Step 13

Select from the Menu, View then Code

2015-view-code

Step 14

Once in the Code View below the public Page() { … } the following should be entered:

public Library Library = new Library();

private void Display_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
	Library.Launch(Display);
}

It should then appear as such:

2015-tailored-app-page-code

Step 15

From the Solution Explorer select App.xaml

2015-app-library

Step 16

Select from the Menu, View then Code

2015-view-code

Step 17

Once in the Code View in protected override void OnLaunched(LaunchActivatedEventArgs e) { … } the following should be entered above rootFrame.Navigate(typeof(MainPage), e.Arguments);:

if (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily.Contains("Mobile"))
{
	rootFrame.Navigate(typeof(SecondaryPage), e.Arguments);
	Window.Current.Activate();
	return;
}

It should then appear as such:

2015-tailored-app-app-code

Step 18

From the Solution Explorer select MainPage.xaml

2015-mainpage-library

Step 19

Select from the Menu, View then Designer

2015-view-designer

Step 20

The Design View will be displayed along with the XAML View and in this below <Grid Background=”{ThemeResource ApplicationPageBackgroundThemeBrush}”> enter the following XAML:

<GridView Name="Display" HorizontalAlignment="Center" VerticalAlignment="Center"
	SelectionChanged="Display_SelectionChanged" 
	ItemTemplate="{StaticResource Desktop}" 
	ItemsPanel="{StaticResource DesktopItems}"
	ItemsSource="{x:Bind Path=Library.Settings}"/>

It should appear as such:

2015-tailored-app-mainpage-xaml

Step 21

Select from the Menu, View then Code

2015-view-code

Step 22

Once in the Code View below the public MainPage() { … } the following should be entered:

public Library Library = new Library();

private void Display_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
	Library.Launch(Display);
}

It should then appear as such:

2015-tailored-app-mainpage-code

Step 23

That completes the Universal Windows Application so Save the Project then select the Debug and Simulator option to run the Application

2015-simulator

Step 24

Once the Simulator has started the Application should then appear displaying the Desktop view of the Application

2015-tailored-app-simulator-run

Step 25

To Exit the application select Stop Debugging in Visual Studio Community 2015

2015-stop

Step 26

Another option is to run as a Windows 10 Mobile application, select Debug and select Emulator 10.0.10586.0 WVGA 4 inch 512MB option to run the Application

2015-emulator

Step 27

Once the Emulator has started the Application should then appear displaying the Mobile view of the Application

2015-tailored-app-emulator-run

Step 28

To Exit the application select Stop Debugging in Visual Studio Community 2015

2015-stop

Creative Commons License

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s