-->

Thursday, April 9, 2015

Getting Started with Grid App in Windows Store App

Introduction

In the preceding example, we saw getting started with windows store app. Today we will Getting started with grid app. Create a new Grid app project under visual studio 2013 and run this application without any changes. First of all, you will see splash screen on your window screen. Like

Default screen of Grid app in windows screen
Above given snap contains multiple group titles, Group titles contains multiple item title and each item titles having three fields, such as Item picture, Item Title, and item Sub title. When we click on group title , appear new splash screen in windows look like this.
 Splash screen contains group detail page
 Splash screen contains group detail page, which is contain large image with description text(about group title). In right hand side, you can see all item titles with thumbnail image. When we will click on item title , new splash screen will appear on window look like.
 item title , new splash screen
Now, look at in solution explorer, which is contains four .xaml file such as
  1. App.xaml
  2. GroupDetailPage.xaml
  3. GroupedItemsPage.xaml
  4. ItemDetailPage.xaml

If you want to change in all three file then we will implement own code for it. If you want to change app name in windows store then should go for App.xaml file

<x:String x:Key="AppName">Type your application name here</x:String>
For example
<x:String x:Key="AppName">Windows Store App</x:String>

Output Screen

change app name in windows store

How to use Style property in windows store app

Step-1 :  Double-click MainPage.xaml in Solution Explorer to open it.
Step-2 :  In XAML or design view, add a TextBlock with some Text like " Greeting".
Step-3 :  In the Properties Window, Expand the Miscellaneous group and find the Style property.
How to use Style property in windows store app
Step-4 : Click the property marker next to the Style property to open the menu.
Step-5 : In the menu, select System Resource > BodyTextBlockStyle.

How to use Style property in windows store app
when your mouse pointer come to object(TextBlock), a blue outline shows where the TextBlock is so you can select it.

Complete Source code

<Page
    x:Class="App4.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App4"
    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 HorizontalAlignment="Left" Margin="184,216,0,0" TextWrapping="Wrap" Text="Greeting" FontSize="20" VerticalAlignment="Top" Height="44" Width="349" Style="{StaticResource BodyTextBlockStyle}"/>

    </Grid>
</Page>

Wednesday, April 8, 2015

How to change style, theme of page in windows store

If you want to change your page theme, use RequestTheme property  in App.Xaml file. Basically theme is designed for better look. Bydefault, our windows store app uses dark theme. The System resource also included a light theme.

In Solution Explorer, double click App.xaml to open it.
In the opening Application tag, add the RequestedTheme property with its value set to Light.

App.xaml file 

<Application
    x:Class="App4.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App4" RequestedTheme="Light">

</Application>

Lets see after set the property

How to change style, theme of page in windows store
Your background theme will be changed after set property.

How to modify the start page in windows store app

In this tutorial, you learn how to

  • Before you start
  • Create a new project.

Before you start...

Create a new project in Visual Studio

Step-1 : Launch Visual Studio 2013.
Step-2 : Select File > New Project.
Step-3 : In the left pane, expand Installed > Templates, then expand Visual Basic or Visual C# and pick the Windows Store template type.
Step-4 : In the center pane, select the Blank App template.
Step-5 : In the Name text box, according name you enter.
Step-6 : Click OK to create the project.
Step-7 : Remove MainPage.xam file from the solution explorer
Step-8 : Add basic page to solution explorer and assign name to Page as "MainPage.xaml" instead of BasicPage1
Step-9 : Click ok

modify the start page

Step-1 : Double-click MainPage.xaml in Solution Explorer to open it
Step-2 : For change the page title, select the "My Application" text near the top of the page in the XAML designer.
How to modify the start page in windows store app

Use of CheckBox Control in windows store app

Desing Page


<Page
    x:Class="App1.checkBox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    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}">

        <CheckBox x:Name="check1" Content="MVC" HorizontalAlignment="Left" Margin="263,152,0,0" VerticalAlignment="Top" Height="45" Width="256" Checked="check1_Checked" />

        <CheckBox x:Name="check2" Content="ASP.NET" HorizontalAlignment="Left" Margin="263,81,0,0" VerticalAlignment="Top" Height="45" Width="256" Checked="check2_Checked_1" />
        <Button Content="Check " HorizontalAlignment="Left" Margin="242,287,0,0" VerticalAlignment="Top" Width="137" Click="Button_Click"/>

        <TextBlock  FontSize="20" x:Name="Label1" HorizontalAlignment="Left" Margin="387,84,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="113" Width="223"/>

    </Grid>
</Page>

// Code behind file


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=234238

namespace App1
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class checkBox : Page
    {
        public checkBox()
        {
            this.InitializeComponent();
         
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (check1.IsChecked == true)
            {
                Label1.Text += check2.Content+"\n";
            }
            if (check2.IsChecked == true)
            {
                Label1.Text += check1.Content;
            }  
        }


        private void check2_Checked_1(object sender, RoutedEventArgs e)
        {

        }

        private void check1_Checked(object sender, RoutedEventArgs e)
        {

        }
    }
}

Code Generate the following output

Use of CheckBox Control in windows store app

Tuesday, April 7, 2015

Bind Image in code file, Windows Store App

Design Page

<Page
    x:Class="App1.ImageCode"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    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}">
        <Image x:Name="image1" HorizontalAlignment="Left" Height="246" Margin="113,131,0,0" VerticalAlignment="Top" Width="296"/>

    </Grid>
</Page>

// Code behind file


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.Media.Imaging;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace App1
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class ImageCode : Page
    {
        public ImageCode()
        {
            this.InitializeComponent();
            BitmapImage bi = new BitmapImage();
            bi.UriSource = new Uri(this.BaseUri, "joli.jpg");
            image1.Source = bi;


        }
    }
}

Code Generate the following output

Bind Image in code file, Windows Store App

Use Of Image Control in windows Store App

<Page
    x:Class="App1.imagecontro"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    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}">


        <Image Source="joli.jpg" HorizontalAlignment="Left" Height="279" Margin="240,138,0,0" VerticalAlignment="Top" Width="399"/>

    


    </Grid>
</Page>

Code Generate the following output

Use Of Image Control in windows Store App

Monday, April 6, 2015

Example of Hyperlink control in windows store app Tutorial

How to Navigate from page to specific URL

 Add HyperlinkButton control with specified code , code is

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

        <HyperlinkButton FontSize=" 30" Content="Google.com" NavigateUri=" http://www.google.com" Margin="272,218,0,475" Height="75" />

    </Grid>

This code add into MainPage.xaml file
Code generate the following output
windows store How to Navigate from page to specific URLwindows store How to Navigate from page to specific URL


How to Navigate from one page to another page in windows store app tutorial

Add click event handler with HyperLinkButton control look like

Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

        <HyperlinkButton Click="HyperlinkButton_Click" FontSize=" 30" Content="Move to Next page"  Margin="272,218,0,475" Height="75" />

    </Grid>
Add Handler code in MainPage.xaml.cs file

  private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
        {
            this.Frame.Navigate(typeof(secondpage));

        }
Code Generate the following output
How to Navigate from one page to another page in windows store app tutorial

How to Navigate from one page to another page in windows store app tutorial

Windows Store: Hello World !

In this tutorial, you learn how to

  • Before you start
  • Create a new project
  • Hello World Output

Before you start...

Create a new project in Visual Studio

Step-1 : Launch Visual Studio 2013.
Step-2 : Select File > New Project.
Step-3 : In the left pane, expand Installed > Templates, then expand Visual Basic or Visual C# and pick the Windows Store template type.
Step-4 : In the center pane, select the Blank App template.
Step-5 : In the Name text box, enter name according you.
Step-6 : Click OK to create the project.

    <Page
    x:Class="App3.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App3"
    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="Hello World" FontSize="100" />
    </Grid>
    </Page>

    Windows Store: Hello World !

    if you run the application at this point, you should see a nice "Hello World" message. If you're running the default themes, it will be white text on a black background.


    Thursday, November 21, 2013

    Windows Store App : How to use Grid in XAML

    Introduction

    By-default a Grid element has one row and one column i.e. a single cell, any control placed inside the Grid will be placed in this cell. Lets see the below simple XAML code where a textbox is placed in the first row and first column. Programmer is not specifying here, but it have value of Grid.Row as well as Grid.Column property to zero.

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
            <TextBlock Text="Hello World" />
    </Grid>

    How to Insert multiple Rows and Columns in Grid

    Step-1 : Create <Grid.RowDefinitions> and <Grid.ColumnDefinitions > inside the Grid.

      <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
            <Grid.RowDefinitions>              
            </Grid.RowDefinitions>

            <Grid.ColumnDefinitions >             
            </Grid.ColumnDefinitions>

    </Grid>
    Step-2: Lets create Three rows and three columns, by adding three RowDefinition and ColumnDefinition child as in below code.

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
            <Grid.RowDefinitions>   
                <RowDefinition Height="150"/>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
               
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions >          
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

    </Grid>

    Here we have three rows and three column. Every row contains height attribute and column contains width attribute.The first row's height, expressed as an integer value for a pixel count. In the second row's height, described by a literal "Auto" or you can say height will adjust according to the content which will placed inside the grid. In third row's height, described by the asterisk character(*)  means you can say the last row will take remaining space of the grid.

    How to place controls in rows and columns 

    Generally grid is used when we are placing elements in no. of rows and columns. Suppose we want to move control to the second row and second column. To do that we have to set the value of Grid.Row and Grid.Column attribute of the respective element. Review the following XAML:

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
            <Grid.RowDefinitions>   
                <RowDefinition Height="150"/>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
               
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions >          
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <TextBlock x:Name="firstBlock" Text=" Hello World" Grid.Row="1" Grid.Column="1" />
        </Grid>

    Look out the above code, i have set the value of Grid.Row and Grid.Column to 1 for textbox element. By this it will placed in the second row and second column.

    Design view of the code

    Grid row definition and column definition in xaml: Windows Store App

    Here your snap simplifies relation between TextBlock and Grid. Lets take a simple theory to understand how to define TextBlock outside the Grid.RowDefinitions and Grid.ColumnDefinitions.

    Suppose you have three fruits apple, grapes and orange now you want to place all of them in individual row and column. Then you can simply place these items in the specified rows and column using Grid.Row and Grid.Column attribute.

    Tuesday, November 19, 2013

    How to change Application name in Windows Store Grid App

    Introduction

    In our previous article, we have studied about Windows Store Grid App. In this article we will learn about App.xaml file and their behaviors also take a simple example to change Application name.

    Pre-requisite

    • You need windows 8 SDK
    • You need developer license

    General Structure of App.xaml file

    <Application
        x:Class="FirstGridApplication.App"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:FirstGridApplication"
        xmlns:localData="using:FirstGridApplication.Data">

        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>

                    <!--
                        Styles that define common aspects of the platform look and feel
                        Required by Visual Studio project and item templates
                     -->
                    <ResourceDictionary Source="Common/StandardStyles.xaml"/>
                </ResourceDictionary.MergedDictionaries>

                <!-- Application-specific resources -->

                <x:String x:Key="AppName">FirstGridApplication</x:String>
            </ResourceDictionary>
        </Application.Resources>

    </Application>

    If you want to change Application name in Grid App then you should go for  App.xaml file and change in markup as specified in below XAML code

     <x:String x:Key="AppName">FirstGridApplication</x:String>

    First Output Page
    How to change Application name in Windows Store Grid App

    <x:String x:Key="AppName">My Application</x:String>

    After change Output will become

    How to change Application name in Windows Store Grid App



    © Copyright 2013 Computer Programming | All Right Reserved