Windows 10 Development – Useful Resources ”; Previous Next The following resources contain additional information on Windows 10 Development. Please use them to get more in-depth knowledge on this. Useful Video Courses Windows 10 Online Training Course Best Seller 24 Lectures 2 hours Tutorialspoint More Detail Windows 10 Installation, Config, Protect and Maintaining 53 Lectures 9 hours Fabrice Chrzanowski More Detail Using Microsoft Windows 10 49 Lectures 2 hours Sonic Performance More Detail Using Windows 10 for Beginners Plus Upgrading to Windows 11 16 Lectures 3.5 hours David W Cox More Detail Easy C# .NET Core by Live Project in Windows Forms & SQL Database Featured 4 Lectures 0 mins Abdullah Musavi More Detail Microsoft Windows 10 OS Masterclass 20 Lectures 2 hours Fredrick Ezeh More Detail Print Page Previous Next Advertisements ”;
Category: windows10 Development
Windows 10 – App Lifecycle
Windows 10 Development – Lifecycle ”; Previous Next Historically, Windows has environment, where users can run multiple applications simultaneously. User can switch between different applications easily. This model does not work well for phone or tablet devices where the usage is typically single-application focused. One of the most significant challenges facing Windows 8 Store application programmers will be managing and understanding the application lifecycle. If you have been building Windows phone applications, then much of this would be familiar. Under Windows 8, the operating system manages the lifetime of an application, and while the user can terminate an application, typically the user opens new applications without consciously terminating running applications. The Universal Windows Platform (UWP) for Windows 10 addresses these issues, offering some cool stuff to the desktop users so that multiple applications can run with a multiple windowed experience. Windows applications can exist in three states at the basic level as shown below. Running Suspended Terminate When a user launches/activates any application, then it goes in the running state. Applications can be suspended if a user does not use it and it is no longer in the foreground. From the Suspended state, applications can either resume that application or terminate the OS in order to reclaim system resources. Process State Transition It is important to understand the process state transitions in a running application. When the user first launches the application, the splash screen is shown and then the application starts running. The process can be explained as follows − When the application is suspending, your app gets five seconds to handle that suspended event. When the application is suspended, absolutely no code runs and no resources are allocated. When it resumes, the app is notified that it has resumed. If you are coming from a suspended state, you need to take no action. Under memory pressure, it is possible for your application to be terminated. Remember that you will not be notified at that point, and so any saving you do, you have to do when you enter into the suspended application state. When the application transits back and forth between Running and Suspended states, fire suspending and resuming events respectively. Sometimes, you need to save data. Then you have to call asynchronous methods as shown below. Application.Current.Suspending += new SuspendingEventHandler(App_Suspending); async void App_Suspending(Object sender, Windows.ApplicationModel.SuspendingEventArgs e){ // Create a simple setting localSettings.Values[“FirstName”] = fName.Text; localSettings.Values[“LastName”] = lName.Text; localSettings.Values[“Email”] = email.Text; } Application.Current.Resuming += new EventHandler<Object>(App_Resuming); private void App_Resuming(Object sender, Object e){ fName.Text = localSettings.Values[“FirstName”]; lName.Text = localSettings.Values[“LastName”]; email.Text = localSettings.Values[“Email”]; } Let us study an example in which controls are added as shown in the below given XAML file. <Page x:Class = “UWPLifeCycleDemo.MainPage” xmlns = “http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x = “http://schemas.microsoft.com/winfx/2006/xaml” xmlns:local = “using:UWPLifeCycleDemo” xmlns:d = “http://schemas.microsoft.com/expression/blend/2008” xmlns:mc = “http://schemas.openxmlformats.org/markup-compatibility/2006” mc:Ignorable = “d”> <Grid Background = “{ThemeResource ApplicationPageBackgroundThemeBrush}”> <Hub Header = “Details” /> <StackPanel VerticalAlignment = “Top” HorizontalAlignment = “Left” Margin = “12,64,0,0”> <TextBox Header = “First Name” Text = “{Binding FirstName, Mode = TwoWay, UpdateSourceTrigger = PropertyChanged}” Width = “200” /> <TextBox Header = “Last Name” Text = “{Binding LastName, Mode = TwoWay, UpdateSourceTrigger = PropertyChanged}” Width = “200” /> <TextBox Header = “Email” Text = “{Binding Email, Mode = TwoWay, UpdateSourceTrigger = PropertyChanged}” Width = “200” /> <Button Margin = “0,12”>Submit</Button> </StackPanel> </Grid> </Page> Given below is the C# code in which the Suspend and Resume events are implemented. The current data will be stored in the suspend event in local settings and then the data will be retrieved in the resume event from local settings as shown below. using System; using System.ComponentModel; using System.Runtime.CompilerServices; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; namespace UWPLifeCycleDemo { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class MainPage : Page{ var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; public MainPage() { this.InitializeComponent(); Application.Current.Suspending += new SuspendingEventHandler(App_Suspending); Application.Current.Resuming += new EventHandler<Object>(App_Resuming); } async void App_Suspending(Object sender, Windows.ApplicationModel.SuspendingEventArgs e){ // Create a simple setting localSettings.Values[“FirstName”] = fName.Text; localSettings.Values[“LastName”] = lName.Text; localSettings.Values[“Email”] = email.Text; } private void App_Resuming(Object sender, Object e){ fName.Text = localSettings.Values[“FirstName”]; lName.Text = localSettings.Values[“LastName”]; email.Text = localSettings.Values[“Email”]; } } public abstract class BindableBase : INotifyPropertyChanged { private string _FirstName = default(string); public string FirstName { get { return _FirstName; } set { Set(ref _FirstName, value); } } private string _LastName = default(string); public string LastName { get { return _LastName; } set { Set(ref _LastName, value); } } private string _Email = default(string); public string Email { get { return _Email; } set { Set(ref _Email, value); } } public event PropertyChangedEventHandler PropertyChanged; public void RaisePropertyChanged([CallerMemberName]string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } public void Set<T>(ref T storage, T value, [CallerMemberName()]string propertyName = null){ if (!object.Equals(storage, value)){ storage = value; RaisePropertyChanged(propertyName); } } } } When the above code is compiled and executed, you will see the following window. Now write the desired information. Let us go to the Lifecycle Events dropdown menu and select suspended. Now your application will be suspended and the desired information will be stored in local settings. See the screenshot given below. Now, when you want to resume your application, select the option Resume from the Lifecycle Events menu. Now you will see that the stored information is retrieved from local settings and the application is resumed at the same state from which it was suspended. Print Page Previous Next Advertisements ”;
Windows 10 – Navigation
Windows 10 Development – Navigation ”; Previous Next In Universal Windows Platform (UWP) applications, navigation is a flexible model of navigation structures, navigation elements, and system level features. It enables a variety of intuitive user experiences for moving between apps, pages, and content. There are some situations and scenarios where all of the content and functionality can easily fit into a single page and there is no need for the developers to create multiple pages. However, in majority of the applications, multiple pages are used for interaction between different content and functionality. When an app has more than one page, then it is very important for the developers to provide the right navigation experience. Page Models Typically, in Universal Windows Platform (UWP) applications, single page navigation model is used. Important features are − A single page navigation model maintains all the context of your application and additional content and data into a central frame. You can divide the content of your application into multiple pages. However, when moving from one page to another, your application loads the pages into a main page form. Neither the main page of your application is unloaded nor the code and data is unloaded, it makes it easier to manage state, and provide smoother transition animations between pages. Multi-page navigation is also used for navigating between different pages or screens without worrying about the application context. In multi-page navigation, each page has its own set of functions, user interface and data etc. Multi-pages navigation is typically used in web pages within the website. Navigation Structure In multi-page navigation, each page has its own set of functions, user interface and data etc. For example, a photo application may have one page for capturing photos, then when the user wants to edit the photo, it navigates to another page and to maintain the image library, it has another page. The navigation structure of your application is defined by how these pages are organized. Following are the ways to structure navigation in your application − Hierarchy In this type of navigation structuring, Pages are organized into a tree like structure. Each child page has only one parent, but a parent can have one or more child pages. To reach a child page, you have to travel through the parent. Peer In this type of navigation − Pages exist side by side. You can go from one page to another in any order. In most of the multi-pages applications, both structures are used simultaneously. Some of the pages are organized as peers and some of them are organized into hierarchies. Let us take an example that contains three pages. Create a blank UWP application with the name UWPNavigation. Add two more blank pages by right clicking on the project in Solution Explorer and select Add > New Item option from the menu, which will open the following dialog window. Select the Blank page from the middle pane and click the Add button. Now add one more page by following the above given steps. You will see three pages in the Solution Explorer − MainPage, BlankPage1, and BlankPage2. Given below is the XAML code for MainPage in which two buttons are added. <Page x:Class = “UWPNavigation.MainPage” xmlns = “http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x = “http://schemas.microsoft.com/winfx/2006/xaml” xmlns:local = “using:UWPNavigation” xmlns:d = “http://schemas.microsoft.com/expression/blend/2008” xmlns:mc = “http://schemas.openxmlformats.org/markup-compatibility/2006” mc:Ignorable = “d”> <Grid Background = “{ThemeResource ApplicationPageBackgroundThemeBrush}”> <Hub Header = “Hi, this Main Page”/> <Button Content = “Go to Page 1” Margin = “64,131,0,477” Click = “Button_Click”/> <Button Content = “Go to Page 2” Margin = “64,210,0,398” Click = “Button_Click_1″/> </Grid> </Page> Given below is the C# code for two buttons on MainPage, which will navigate to the other two pages. using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 namespace UWPNavigation { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e){ this.Frame.Navigate(typeof(BlankPage1)); } private void Button_Click_1(object sender, RoutedEventArgs e) { this.Frame.Navigate(typeof(BlankPage2)); } } } The XAML code for blank page 1 is shown below. <Page x:Class = “UWPNavigation.BlankPage1” xmlns = “http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x = “http://schemas.microsoft.com/winfx/2006/xaml” xmlns:local = “using:UWPNavigation” xmlns:d = “http://schemas.microsoft.com/expression/blend/2008” xmlns:mc = “http://schemas.openxmlformats.org/markup-compatibility/2006” mc:Ignorable = “d”> <Grid Background = “{ThemeResource ApplicationPageBackgroundThemeBrush}”> <Hub Header = “Hi, this is page 1″/> <Button Content = “Go to Main Page” Margin = “64,94,0,514” Click = “Button_Click”/> </Grid> </Page> C# code for button – click event on blank page 1, which will navigate to main page is shown below. using System; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 namespace UWPNavigation { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class BlankPage1 : Page { public BlankPage1() { this.InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { this.Frame.Navigate(typeof(MainPage)); } } } Given below is the XAML code for blank page 2. <Page x:Class = “UWPNavigation.BlankPage2” xmlns = “http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x = “http://schemas.microsoft.com/winfx/2006/xaml” xmlns:local = “using:UWPNavigation” xmlns:d = “http://schemas.microsoft.com/expression/blend/2008” xmlns:mc = “http://schemas.openxmlformats.org/markup-compatibility/2006” mc:Ignorable = “d”> <Grid Background = “{ThemeResource ApplicationPageBackgroundThemeBrush}”> <Hub Header = “Hi, this is page 2″/> <Button Content = “Go to Main Page” Margin = “64,94,0,514” Click = “Button_Click”/> </Grid> </Page> Given below is the C# code for button click event on blank page 2, which will navigate to the main page. using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 namespace UWPNavigation { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class BlankPage2 : Page { public BlankPage2(){ this.InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { this.Frame.Navigate(typeof(MainPage)); } } } When the above code is compiled and executed, you will see the following window. When you click on any button, it will navigate you to the respective
Windows 10 – Home
Windows 10 Development Tutorial PDF Version Quick Guide Resources Job Search Discussion Welcome to Windows 10 tutorial. This tutorial is designed for people who want to learn how to develop apps meant for Windows 10. After completing it, you will have a better understating of Windows apps and what you can do with Windows applications using XAML and C#. Audience This tutorial has been prepared for anyone who has a basic knowledge of XAML, C#, and Visual Studio and has an urge to develop apps for mobile or desktop. Prerequisites Before you start proceeding with this tutorial, we are assuming that you have a good understanding of the basics of XAML, C#, and Visual Studio. If you are not well aware of these concepts, then we will suggest you to go through our short tutorials on these topics. Print Page Previous Next Advertisements ”;
Windows 10 – Communication
Windows10 Dev – App Communication ”; Previous Next App to app communication means that your application can speak to or communicate with another application that is installed on the same device. This is not a new feature in Universal Windows Platform (UWP) application and was also available in Windows 8.1. In Windows 10, some new and improved ways are introduced to easily communicate between applications on the same device. Communication between two apps can be in the following ways − One application launching another app with some data. Apps are simply exchanging data without launching anything. The main advantage of app to app communication is that you can break applications into smaller chunks, which can be maintained, updated and consumed easily. Getting Your App Ready If you Follow the steps given below, other applications can launch your application. Add a protocol declaration in application package manifest. Double click on the Package.appxmanifest file, which is available in the Solution Explorer as shown below. Go to the Declaration tab and write the Name of the protocol as shown below. The next step is to add the activation code, so the app can respond appropriately when launched by the other application. To respond to protocol activations, we need to override the OnActivated method of the activation class. So, add the following code in App.xaml.cs file. protected override void OnActivated(IActivatedEventArgs args) { ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs; if (args != null){ Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null){ // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // Set the default language rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; rootFrame.NavigationFailed += OnNavigationFailed; // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null){ // When the navigation stack isn”t restored, navigate to the // first page, configuring the new page by passing required // information as a navigation parameter rootFrame.Navigate(typeof(MainPage), null); } // Ensure the current window is active Window.Current.Activate(); } } To launch the application, you can simply use the Launcher.LaunchUriAsync method, which will launch the application with protocol specified in this method. await Windows.System.Launcher.LaunchUriAsync(new Uri(“win10demo:?SomeData=123”)); Let us understand this with a simple example in which we have two UWP applications with ProtocolHandlerDemo and FirstProtocolHandler. In this example, the ProtocolHandlerDemo application contains one button and by clicking on the button, it will open the FirstProtocolHandler application. XAML code in the ProtocolHandlerDemo application, which contains one button is given below. <Page x:Class = “ProtocolHandlerDemo.MainPage” xmlns = “http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x = “http://schemas.microsoft.com/winfx/2006/xaml” xmlns:local = “using:ProtocolHandlerDemo” xmlns:d = “http://schemas.microsoft.com/expression/blend/2008” xmlns:mc = “http://schemas.openxmlformats.org/markup-compatibility/2006” mc:Ignorable = “d”> <Grid Background = “{ThemeResource ApplicationPageBackgroundThemeBrush}”> <Button x:Name = “LaunchButton” Content = ” Launch First Protocol App” FontSize = “24” HorizontalAlignment = “Center” Click = “LaunchButton_Click”/> </Grid> </Page> Given below is the C# code, in which the button click event is implemented. using System; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 namespace ProtocolHandlerDemo { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class MainPage : Page { public MainPage(){ this.InitializeComponent(); } private async void LaunchButton_Click(object sender, RoutedEventArgs e) { await Windows.System.Launcher.LaunchUriAsync(new Uri(“win10demo:?SomeData=123”)); } } } Now let us have a look into the FirstProtocolHandler application table. Given below is the XAML code in which a textblock is created with some properties. <Page x:Class = “FirstProtocolHandler.MainPage” xmlns = “http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x = “http://schemas.microsoft.com/winfx/2006/xaml” xmlns:local = “using:FirstProtocolHandler” xmlns:d = “http://schemas.microsoft.com/expression/blend/2008” xmlns:mc = “http://schemas.openxmlformats.org/markup-compatibility/2006” mc:Ignorable = “d”> <Grid Background = “{ThemeResource ApplicationPageBackgroundThemeBrush}”> <TextBlock Text = “You have successfully launch First Protocol Application” TextWrapping = “Wrap” Style = “{StaticResource SubtitleTextBlockStyle}” Margin = “30,39,0,0” VerticalAlignment = “Top” HorizontalAlignment = “Left” Height = “100” Width = “325”/> </Grid> </Page> The C# implementation of the App.xaml.cs file in which OnActicated is overriden is shown below. Add the following code inside App class in the App.xaml.cs file. protected override void OnActivated(IActivatedEventArgs args) { ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs; if (args != null) { Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // Set the default language rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; rootFrame.NavigationFailed += OnNavigationFailed; // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn”t restored navigate to the // first page, configuring the new page by passing required // information as a navigation parameter rootFrame.Navigate(typeof(MainPage), null); } // Ensure the current window is active Window.Current.Activate(); } } When you compile and execute the ProtocolHandlerDemo application on an emulator, you will see the following window. Now, when you click on the button, it will open the FirstProtocolHandler application as shown below. Print Page Previous Next Advertisements ”;
Windows 10 – Adaptive Code
Windows 10 Development – Adaptive Code ”; Previous Next In this chapter, we will be demonstrating the adoption of your application to different devices supported by Windows 10. We have already learnt about adopting your UI and all the tricks, techniques and controls used in UWP applications. Now, we will learn about adopting your code, because Application codes are not the same across all the devices. APIs used, particularly for Xbox, will not be available for mobile devices. The same thing is true for HoloLens etc. Adaptive code can light up your application conditionally and execute code only when running on a specific device family and/or on a particular version of the platform/extension APIs. Writing Code In Windows 10, you can implement the UWP applications in Visual Studio by using either C++, C#, Visual Basic or JavaScript. With C# and Visual Basic you can use XAML for UI designing. With C++ you can either use DirectX instead of using XAML. For JavaScript, you can use HTML for your presentation layer, which is a cross platform Web standards. The Windows Core APIs run in the same way for all the devices, which contain most of the functionality you need for your code and UI. However, for the code and the UI tailored for particular device families, you need to use the adaptive code and adaptive UI. Calling an API that is NOT implemented by the target device family − The UI adapts to different screens easily, but different device families not only have different screen sizes, it has a lot more than that. For example, the mobile phones have some hardware buttons such as Back and Camera, which might not be available on other devices such as PC. By default, the core APIs contain most of the functionality, which works for all the devices, but the device specific functionality can be used by referencing the Extension SDKs in your UWP applications just like external assemblies. To add any particular extension SDK, needed in your application, follow the below given steps − Right click on the References. Select “Add References..”. The following dialog will open. Adding an extension is as simple as adding a project reference. Now you can add any extension SDK from the list, which contains Desktop Extension, IoT Extension, and Mobile Extension etc. Desktop and Mobile extensions are the two most common platform Extension SDKs. The Mobile extension, for example, enables the APIs necessary to use the hardware camera button. You can check the device capabilities by using the Windows.Foundation.Metadata.ApiInformation class method, which returns a Boolean output if the type is supported on the current device. For example, you can enable your Windows app to use the Camera button with code like this − bool isHardwareButtonsAPIPresent = Windows.Foundation.Metadata.ApiInformation. IsTypePresent(“Windows.Phone.UI.Inpu t.HardwareButtons”); if (isHardwareButtonsAPIPresent) { Windows.Phone.UI.Input.HardwareButtons.CameraPressed += HardwareButtons_CameraPressed; } The phone-camera button code will execute only if the Mobile Extension SDK is enabled on the device. Similarly, you can also check for any particular event, method or property in the current API version by using IsEventPresent, IsMethodPresent, IsPropertyPresent, instead of IsTypePresent as shown below. bool isHardwareButtons_CameraPressedAPIPresent = Windows.Foundation.Metadata.ApiInformation.IsEventPresent (“Windows.Phone.UI.Input.HardwareButtons”, “CameraPressed”); Win32 APIs in the UWP A Universal Widows Platform (UWP) application or Windows Runtime Component, which are written in C++/CX, can access Win32 APIs, which are also a part of UWP now. All of the Windows 10 device families can implement Win32 APIs by linking your application with Windowsapp.lib. Windowsapp.lib is an “umbrella” lib that provides the exports for the UWP APIs. Linking to Windowsapp.lib will add to your app dependencies on dlls that are present on all Windows 10 device families. Let us have a look into a simple example in which the application targets both the desktop and the phone. Therefore, when the application runs on the desktop, it will not show the status bar, but when the same application runs on the phone, it will display the status bar. Given below is the XAML code in which different controls are added. <Page x:Class = “UWPAdoptiveCode.MainPage” xmlns = “http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x = “http://schemas.microsoft.com/winfx/2006/xaml” xmlns:local = “using:UWPAdoptiveCode” xmlns:d = “http://schemas.microsoft.com/expression/blend/2008” xmlns:mc = “http://schemas.openxmlformats.org/markup-compatibility/2006” mc:Ignorable = “d”> <Page.Background> <SolidColorBrush Color = “Green”/> </Page.Background> <Page.BottomAppBar> <CommandBar x:Name = “commandBar” > <AppBarButton Icon = “Accept” Label = “appbarbutton”/> <AppBarButton Icon = “Cancel” Label = “appbarbutton”/> </CommandBar> </Page.BottomAppBar> <Grid Background = “AliceBlue”> <VisualStateManager.VisualStateGroups> <VisualStateGroup> <VisualState> <VisualState.StateTriggers> <local:DeviceFamilyTrigger DeviceFamily = “Desktop” /> </VisualState.StateTriggers> <VisualState.Setters> <Setter Target = “StatusBarControls.Visibility” Value = “Collapsed”/> </VisualState.Setters> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <StackPanel HorizontalAlignment = “Left” Margin = “75,164,0,0” VerticalAlignment = “Top” > <RadioButton x:Name = “ShowAppBarRadioButton” Content = “Show AppBar” HorizontalAlignment = “Stretch” VerticalAlignment = “Stretch” IsChecked = “True” Checked = “RadioButton_Checked”/> <RadioButton x:Name = “ShowOpaqueAppBarRadioButton” Content = “Show Transparent AppBar” HorizontalAlignment = “Stretch” VerticalAlignment = “Stretch” Checked = “RadioButton_Checked”/> <RadioButton x:Name = “HideAppBarRadioButton” Content = “Hide AppBar” HorizontalAlignment = “Stretch” VerticalAlignment = “Stretch” Checked = “RadioButton_Checked”/> </StackPanel> <StackPanel x:Name = “StatusBarControls” Orientation = “Vertical” Margin = “75,350,0,0” Visibility = “Visible”> <CheckBox x:Name = “StatusBarBackgroundCheckBox” Content = “Set StatusBar Background” Checked = “StatusBarBackgroundCheckBox_Checked” Unchecked = “StatusBarBackgroundCheckBox_Unchecked”/> <CheckBox x:Name = “StatusBarHiddenCheckBox” Content = “Set StatusBar Hidden” Checked = “StatusBarHiddenCheckBox_Checked” Unchecked = “StatusBarHiddenCheckBox_Unchecked”/> </StackPanel> </Grid> </Page> Given below is the C# implementation for different events. using Windows.UI; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 namespace UWPAdoptiveCode { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class MainPage : Page { private Color? DefaultTitleBarButtonsBGColor; private Color? DefaultTitleBarBGColor; public MainPage() { this.InitializeComponent(); //Windows.UI.ViewManagement.ApplicationView.GetForCurrentView(). VisibleBoundsCh anged += MainPage_VisibleBoundsChanged; var viewTitleBar = Windows.UI.ViewManagement.ApplicationView. GetForCurrentView().TitleBar; DefaultTitleBarBGColor = viewTitleBar.BackgroundColor; DefaultTitleBarButtonsBGColor = viewTitleBar.ButtonBackgroundColor; } private void RadioButton_Checked(object sender, RoutedEventArgs e) { // Bottom AppBar shows on Desktop and Mobile if (ShowAppBarRadioButton != null) { if (ShowAppBarRadioButton.IsChecked.HasValue && (ShowAppBarRadioButton.IsChecked.Value == true)) { commandBar.Visibility = Windows.UI.Xaml.Visibility.Visible; commandBar.Opacity = 1; } else { commandBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } } if (ShowOpaqueAppBarRadioButton != null) { if (ShowOpaqueAppBarRadioButton.IsChecked.HasValue && (ShowOpaqueAppBarRadioButton.IsChecked.Value == true)){ commandBar.Visibility = Windows.UI.Xaml.Visibility.Visible; commandBar.Background.Opacity = 0; } else{
Windows 10 – XAML Controls
Windows 10 Development – XAML Controls ”; Previous Next XAML Stands for Extensible Application Markup Language. It is a User Interface framework and it offers an extensive library of controls that support UI development for Windows. Some of them have a visual representation such as a Button, Textbox and TextBlock etc; while other controls are used as the containers for other controls or content, such as images etc. All the XAML controls are inherited from “System.Windows.Controls.Control”. XAML Emerging Story XAML is used in many important Microsoft platforms such as the Windows Presentation Foundation (WPF), the Silverlight and now, Windows apps. Now, Microsoft Office 2016 is also a family of UWP apps. XAML is a rich Platform, which provides very cool features and controls that can be used in UWP applications. The complete inheritance hierarchy of controls is shown below. Layout Controls Layout of Controls is very important and critical for application usability. It is used to arrange a group of GUI elements in your application. There are certain important things to consider while selecting the layout panels − Positions of the child elements. Sizes of the child elements. Layering of overlapping child elements on top of each other. A list of Layout Controls is given below − Given below are the commonly used Layout Controls. S.No. Controls & Description 1 StackPanel StackPanel is a simple and useful layout panel in XAML. In stack panel, child elements can be arranged in a single line either horizontally or vertically based on orientation property. 2 WrapPanel In WrapPanel, child elements are positioned in sequential order from left to right or from top to bottom based on the orientation property. The only difference between StackPanel and WrapPanel is that it does not stack all the child elements into a single line but it wraps the remaining elements to another line if there is no space left. 3 DockPanel DockPanel defines an area to arrange child elements relative to each other, either horizontally or vertically. With DockPanel you can easily dock child elements to top, bottom, right, left and center with Dock property. With LastChildFill property, the last child element fill the remaining space regardless of any other dock value when set for that element. 4 Canvas Canvas is the basic layout panel in which child elements can be positioned explicitly using coordinates that are relative to any side such as left, right, top and bottom. Typically Canvas is used for 2D graphic elements (such as Ellipse, Rectangle etc.) but not for UI elements because specifying absolute coordinates give trouble while resizing, localizing or scaling in an XAML application. 5 Grid Grid provides a flexible area, which consists of rows and columns. In Grid, child elements can be arranged in a tabular form. Elements can be added to any specific row and column by using Grid.Row and Grid.Column properties. 6 SplitView SplitView represents a container with two views; one view for the main content and another view that is typically used for navigation commands. 7 RelativePanel RelativePanel defines an area within which you can position and align child objects in relation to each other or the parent panel. 8 ViewBox ViewBox defines a content decorator that can stretch and scale a single child to fill the available space. 9 FlipView FlipView represents an item’s control that displays one item at a time, and enables “flip” behavior for traversing its collection of items. 10 GridView GridView is a control that presents a collection of items in rows and columns and can be scrolled horizontally. UI Controls Here is a list of UI Controls, which are visible to the end users. Given below are the commonly used UI Controls. S.No. UI Controls & Description 1 Button A control that responds to user input 2 Calendar Represents a control that enables a user to select a date by using a visual calendar display. 3 CheckBox A control that a user can select or clear. 4 ComboBox A drop-down list of items, a user can select from. 5 ContextMenu Gets or sets the context menu element that should appear whenever the context menu is requested through user interface (UI) from within this element. 6 DataGrid Represents a control that displays data in a customizable grid. 7 DatePicker A control that lets a user select a date. 8 Dialogs An application may also display additional windows to do the user to gather or display important information. 9 Flyout Represents a control that displays lightweight UI that is either information, or requires user interaction. Unlike a dialog, a Flyout can be light dismissed by clicking or tapping outside of it, pressing the device’s back button, or pressing the ‘Esc’ key. 10 Image A control that presents an image. 11 ListBox A control that presents an inline list of items that the user can select from. 12 Menus Represents a Windows menu control that enables you to hierarchically organize the elements associated with commands and event handlers. 13 MenuFlyout Represents a flyout that displays a menu of commands. 14 PasswordBox A control for entering passwords. 15 Popup Displays content on top of the existing content, within the bounds of the application window. 16 ProgressBar A control that indicates the progress by displaying a bar. 17 ProgressRing A control that indicates the indeterminate progress by displaying a ring. 18 RadioButton A control that allows a user to select a single option from a group of options. 19 RichEditBox A control that lets a user edit rich text documents with content like formatted text, hyperlinks, and images. 20 ScrollViewer A container control that lets the user pan and zoom its content. 21 SearchBox A control that lets a user enter search queries. 22 Slider A control that lets the user select from a range of values by moving a Thumb control along a track. 23 TextBlock A control that displays the text. 24 TimePicker A control that lets a user set a time value. 25 ToggleButton A button that can
Windows 10 – SQLite Database
Windows 10 Development – SQLite Database ”; Previous Next In many applications, there are certain types of data, which have some sort of relationship to each other. These types of data, which are difficult to store in a file, can be stored in a database. If you are familiar with the types of databases, such as SQL server or Oracle databases in any application, then it is very easy to understand SQLite database. What is SQLite? SQLite is a software library that implements a self-contained, server less, zero-configuration, transactional SQL database engine. Important features are − SQLite is the most widely deployed database engine in the world. The source code for SQLite is Open source. It has had a large impact on game and mobile application development, due to its portability and small footprint. Advantages of SQLite The following are the advantages of SQLite − It is a very lightweight database. It is platform independent and works on all platforms. It has a small memory footprint. It is reliable. No need for any setup and installation. It has no dependencies. To use SQLite in your Universal Windows Platform (UWP) applications, you need to follow the steps given below. Create a new Universal Windows blank app with the name UWPSQLiteDemo. Go to the Tools menu and select Extensions and Updates. The following dialog will open. After selecting Extensions and Updates, the following window will open. Now select the Online option and search for SQLite, from the left pane. Download and Install SQLite for Universal App Platform. Now, go to the Tools menu again and select NuGet Package Manager > Package Manager Console menu option as shown below. Write the following command in the Package Manager Console and press enter to execute this command − Install-Package SQLite.Net-PCL Now right click on References in the solution explorer and select Add References. The following dialog will open. Select Extensions from the left pane under Universal Windows, check SQLite for Universal App Platform in the middle pane, and click Ok. Now you are ready to go and use SQLite in your UWP applications. You can create a database by using the following code. string path = Path.Combine(Windows.Storage.ApplicationData. Current.LocalFolder.Path, “db.sqlite”); SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path); To create a table you need to call CreateTable method with table name object. conn.CreateTable<Customer>(); You can insert the data into your table by using the following code. conn.Insert(new Customer(){ Name = textBox.Text, Age = textBox1.Text }); Given below is the code to retrieve data from the table. var query = conn.Table<Customer>(); string id = “”; string name = “”; string age = “”; foreach (var message in query) { id = id + ” ” + message.Id; name = name + ” ” + message.Name; age = age + ” ” + message.Age; } Let us understand how to create a database, a table and how to insert and retrieve the data from the database with the help of a simple example. We will be adding Name and age and then we will retrieve the same data from the table. Given below is the XAML code in which different controls are added. <Page x:Class = “UWPSQLiteDemo.MainPage” xmlns = “http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x = “http://schemas.microsoft.com/winfx/2006/xaml” xmlns:local = “using:UWPSQLiteDemo” xmlns:d = “http://schemas.microsoft.com/expression/blend/2008” xmlns:mc = “http://schemas.openxmlformats.org/markup-compatibility/2006” mc:Ignorable = “d”> <Grid Background = “{ThemeResource ApplicationPageBackgroundThemeBrush}” > <Button x:Name = “Retrieve” Content = “Retrieve” HorizontalAlignment = “Left” VerticalAlignment = “Top” Margin = “384,406,0,0” Click = “Retrieve_Click”/> <Button x:Name = “Add” Content = “Add” HorizontalAlignment = “Left” VerticalAlignment = “Top” Margin = “291,406,0,0” Click = “Add_Click”/> <TextBlock x:Name = “textBlock” HorizontalAlignment = “Left” TextWrapping = “Wrap” Text = “Name” VerticalAlignment = “Top” Margin = “233,280,0,0” Width = “52”/> <TextBox x:Name = “textBox” HorizontalAlignment = “Left” TextWrapping = “Wrap” VerticalAlignment = “Top” Margin = “289,274,0,0” Width = “370”/> <TextBlock x:Name = “textBlock1” HorizontalAlignment = “Left” TextWrapping = “Wrap” Text = “Age” VerticalAlignment = “Top” Margin = “233,342,0,0” Width = “52”/> <TextBox x:Name = “textBox1” HorizontalAlignment = “Left” TextWrapping = “Wrap” VerticalAlignment = “Top” Margin = “289,336,0,0” Width = “191”/> <TextBlock x:Name = “textBlock2” HorizontalAlignment = “Left” Margin = “290,468,0,0” TextWrapping = “Wrap” VerticalAlignment = “Top” Width = “324” Height = “131”/> </Grid> </Page> Given below is the C# implementation for events and SQLite database. using SQLite.Net.Attributes; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Foundation.Collections; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 namespace UWPSQLiteDemo { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class MainPage : Page { string path; SQLite.Net.SQLiteConnection conn; public MainPage(){ this.InitializeComponent(); path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, “db.sqlite”); conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path); conn.CreateTable<Customer>(); } private void Retrieve_Click(object sender, RoutedEventArgs e) { var query = conn.Table<Customer>(); string id = “”; string name = “”; string age = “”; foreach (var message in query) { id = id + ” ” + message.Id; name = name + ” ” + message.Name; age = age + ” ” + message.Age; } textBlock2.Text = “ID: ” + id + “nName: ” + name + “nAge: ” + age; } private void Add_Click(object sender, RoutedEventArgs e){ var s = conn.Insert(new Customer(){ Name = textBox.Text, Age = textBox1.Text }); } } public class Customer { [PrimaryKey, AutoIncrement] public int Id { get; set; } public string Name { get; set; } public string Age { get; set; } } } When the above code is compiled and executed, you will see the following window. Enter the Name and Age and click the Add button. Now click on the Retrieve button. You will see the following data on the Text Block. The ID field is a Primary Key and Auto Increment field, which is specified in the Customer class. [PrimaryKey, AutoIncrement] public int Id { get; set; } Print Page Previous
Windows 10 – Introduction
Windows 10 Development – Introduction ”; Previous Next This tutorial is designed for people who want to learn how to develop Windows 10 applications. In this tutorial, we are going to learn − Windows 10 application development Updates of the new OS released by Microsoft New features for the developers in the updates A lot of interesting app scenarios are now possible that were not available to us in the first release. Microsoft has not only added new APIs, they have also extended the existing APIs. Universal Windows app A Universal Windows app was first introduced in Windows 8 as the Windows Runtime, which was built upon the Universal Application Platform. Now, in Windows 10, the name of the Universal Application Platform has been changed to Universal Windows Platform (UWP). You can build modern and fully immersive apps by targeting Windows 10 devices for Windows Store such as PC, tablet, phone, etc. In Windows 10, you can easily develop applications to reach all the devices supported on Windows 10 with just − One API set One app package And one store The Universal Windows Platform also supports different screen sizes and different interaction models such as touch pad, mouse & keyboard, a game controller, or a pen. Characteristics of UWP apps Here are some of the characteristics of Universal Windows apps, which make it superior to Windows 10. You can target device families and not OS like Windows 8.1. Apps are packaged and distributed using the .AppX packaging format, which ensures that your apps can be deployed and updated seamlessly. You can submit your application to the Windows store and it will make it available on all device families, or only those devices you choose. You can easily manage all your apps for Windows devices in one place. You can limit the availability of your application to the particular device family. The core APIs of Universal Windows Platform (UWP) are the same across all Windows device families. So your app can run on all Windows 10 devices if it is uses only the core APIs. With the help of Extension SDKs, you can light up your application for particular devices. Development Choices Universal Windows applications can be created in any of the following languages − C# or Visual Basic with XAML JavaScript with HTML C++ with DirectX and/or XAML You can also write components in one language and use them in an application that is developed in another language. Print Page Previous Next Advertisements ”;
Windows 10 – UWP
Windows 10 Development – UWP ”; Previous Next Windows Runtime (WinRT) is a platform-homogeneous application architecture, which supports development in C++/CX, C#, VB.NET and JavaScript. WinRT applications natively support both the x86 and ARM architectures. Some important features are. It was first introduced in Windows Server 2012 in September 2012. WinRT APIs provide access to all core platform features using JavaScript, C#, Visual Basic, and C++. WinRT components support multiple languages and APIs such as native, managed and scripting languages. Universal Windows Platform (UWP) A Universal Windows app is built upon Universal Windows Platform (UWP), which was first introduced in Windows 8 as the Windows Runtime. In Windows 10, Universal Windows Platform (UWP) was introduced, which further advances the Windows Runtime (WinRT) model. In Windows 8.1, WinRT, for the first time, was aligned between Windows Phone 8.1 applications and Windows 8.1 applications with the help of Universal Windows 8 apps to target both Windows phone and Windows application using a shared codebase. Windows 10 Unified Core, which is known as Windows Core now, has reached to a point where UWP, now, provides a common app platform available on every device that runs on Windows 10. UWP not only can call the WinRT APIs that are common to all devices, but also APIs (including Win32 and .NET APIs) that are specific to the device family that the app is running on. Devices Supported by Windows 10 Windows 8.1 and Windows Phone 8.1 apps target an OS; either Windows or Windows Phone. Windows 10 applications do not target an OS but they target one or more device families. Device families have their own APIs as well, which add functionality for that particular device family. You can easily determine all the devices, within a device family, on which your applications can be installed and run from the Windows Store. Here is the hierarchical representation of the device family. Advantages of UWP Universal Windows Platform (UWP) provides a handful of things for developers. They are − One Operating System and One Unified Core for all the devices. One App Platform to run the applications across every family. One Dev Center to submit application and dashboard. One Store for all the devices. Setup for UWP Development The following steps need to be followed to start creating your own Universal Windows Platform (UWP) apps for Windows 10. Windows 10 OS − UWP apps need the latest version of Windows to develop. You can also develop UWP applications on Windows 8.1 but there is no support for UI designer Window. Windows 10 developer tools − In Visual studio 2015, you can design, code, test, and debug your UWP apps. You can download and install the free Microsoft Visual Studio Community 2015 from https://dev.windows.com/en-us/downloads Enable development mode for Windows 10 − Go to Start > Settings. Select Update & security. Then select “For developers”. Click on the Developer mode For UWP apps, it is important to test your applications on devices. Register as an app developer − You can start developing apps, but to submit your apps to the store, you need a developer account. You can create your developer account here https://msdn.microsoft.com/enus/library/windows/apps/bg124287.aspx After following the above steps, you are now ready to start the development of a Universal Windows Platform (UWP) application. Print Page Previous Next Advertisements ”;