ARTICLE

Controls to Design Windows Store Apps

Posted by Krishna Garad Articles | Windows 8 November 29, 2012
In this article we will see the various controls used in Visual Studio 2012 to design our Windows Store application.
Reader Level:

Before reading this article, please go through the following articles:

  1. Developing Windows Store Apps : Introduction And Requirement Specification
  2. Plans For Designing Metro Style Apps (Windows Store Apps)
  3. Windows Store Application Life-Cycle
  4. Guidelines to Pass Windows Store App Certification
  5. Navigation Patterns to Develop Windows Store Application
  6. Templates to Develop Windows Store Apps
  7. Develop Your First Windows Store App (Hello World)

Introduction

In my last article we saw the basic hello world Windows Store application. In that article we only changed the page title to display hello world. In this article we will see the various controls used in Visual Studio 2012 to design our Windows Store application. If you are a developer then you are very familiar with the controls we use to design our applications. If you have developed applications using ASP.Net or some Windows applications then you are familiar with the controls. In ASP.Net we use the control with HTML markup but in Windows Store apps we use XAML markup. If you have some basic knowledge of WPF or Silverlight then it will be very easy to understand Windows Store app development using XAML. Ok whether you are familiar with XAML or not we will see some basic controls with their markup in XAML.

We can create controls for a Windows Store app using one of three ways as follows:

  1. Using XAML markup: You can create the control by defining control markup using XAML.
  2. Using Visual Studio Toolbox: By dragging and dropping a control onto the XAML page.
  3. Using C# code in code behind: By creating a dynamic control using C#.
     

1. Text-Block

As we use a label control in a web application or a Windows application to diasplay static text on our page, in a Windows Store app the label is modified with a TextBlock control to display static text on the page. See the following markup to create a textblock:

<TextBlock x:Name="textBlock1" Text="This is label in windows store apps" />

2. Textbox

To take some input from a user we use this textbox control. It is the same as our ASP.Net textbox control. For example:

<TextBox x:Name="textBox1" Text="Textbox  for windows store app "  />

3. Button

To interact with the user to perform some action. As we know we use a button to execute a block of code. For example:

<Button x:Name="button1" Content="Button"    Click="Button_Click" />

4. Repeat Button

A control to raise the continous click event when it is pressed. For example:

<RepeatButton x:Name="repeatButton1" Content="Repeat Button"               Click="RepeatButton_Click" />

5. Checkbox

A control to take selectional input from the user. For example:

<CheckBox x:Name="checkbox1"  Content="CheckBox"   Checked="CheckBox_Checked"/>

6. Combo-Box

A dropdown control containing a list of items from which the user can select from. For example:

  <ComboBox x:Name="comboBox1" SelectionChanged="ComboBox_SelectionChanged" >
            <x:String>Item 1</x:String>
        <x:String>Item 2</x:String>
        <x:String>Item 3</x:String
>
      </ComboBox>

7. Radio-Button

A control to select only one item from a group. For example:

<RadioButton x:Name="radioButton1" Content="RadioButton 1" GroupName="Group1" />

8. Slider

A control for the user to select a range of values. For example:

<Slider x:Name="slider1" Width="100" ValueChanged="Slider_ValueChanged" />

9. StackPanel

A container control like Panel in ASP.Net to contain child controls. For example:

<StackPanel>
                <Rectangle Fill="Red"/>
               <Rectangle Fill="Blue"/>
               <Rectangle Fill="Green"/>
               <Rectangle Fill="Yellow"
/>
</StackPanel>

10. Canvas

A container control to relatively position child controls. For example:

<Canvas Width="120" Height="120">
                        <Rectangle Fill="Red"/>
                        <Rectangle Fill="Blue" Canvas.Left="20" Canvas.Top="20"/>
                        <Rectangle Fill="Green" Canvas.Left="40" Canvas.Top="40"/>
                        <Rectangle Fill="Yellow" Canvas.Left="60" Canvas.Top="60"
/>
</Canvas>

11. Border

The container control which draws a border around the child controls. For example:
 

<Border BorderBrush="Gray" BorderThickness="4" Height="108"Width="64">

    <StackPanel>

<Rectangle Fill="Yellow"/>

        <Rectangle Fill="Green"/>

    </StackPanel>

</Border>

12. App Bar

A control to display application specific commands or to make navigation among pages in an application like a menu control. For example:

<Page.BottomAppBar>
     <AppBar x:Name="bottomAppBar" Padding="10,0,10,0">
        <Grid>
           <StackPanel Orientation="Horizontal"
>
<Button Style="{StaticResource EditAppBarButtonStyle}" Click="Button_Click"/>
<Button Style="{StaticResource RemoveAppBarButtonStyle}" Click="Button_Click"/>
<Button Style="{StaticResource AddAppBarButtonStyle}" Click="Button_Click"/>
           </StackPanel>           
        </Grid>
    </AppBar
>
</Page.BottomAppBar>


13. Flip View

A control which contains a collection of items where the user can flip through. For example:

<FlipView x:Name="flipView1">
    <Image Source="Assets/Logo.png" />
    <Image Source="Assets/SplashScreen.png" />
    <Image Source="Assets/SmallLogo.png"
/>
</FlipView>


14. Grid

A container control to arrange child elements in rows and columns. For example:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="50"/>
        <RowDefinition Height="50"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="50"/>
        <ColumnDefinition Width="50"/>
    </Grid.ColumnDefinitions>
    <Rectangle Fill="Red"/>
    <Rectangle Fill="Blue" Grid.Row="1"/>
    <Rectangle Fill="Green" Grid.Column="1"/>
    <Rectangle Fill="Yellow" Grid.Row="1" Grid.Column="1"
/>
</Grid>


15. Gridview

A databound control which takes a collection of items to be displayed in rows and columns and which is able to scroll. For example:

<GridView x:Name="gridView1">
    <x:String>Item 1</x:String>
    <x:String>Item 2</x:String
>
</GridView>


16. ListView

A databound control which holds a list of items in a collection. For example:

<ListView x:Name="listView1">
    <x:String>Item 1</x:String>
    <x:String>Item 2</x:String
>
</ListView>
 

17. Password box

A control to take sensitive data input from the user. For example:

<PasswordBox x:Name="passwordBox1"IsPasswordRevealButtonEnabled="True"       />

18. Semantic Zoom

The container control where the user can zoom between two views. For example:

<SemanticZoom>
    <ZoomedInView>
        <GridView></GridView>
    </ZoomedInView>
    <ZoomedOutView>
        <GridView></GridView>
    </ZoomedOutView
>
</SemanticZoom>


19. Progress Bar

A control to display the progress of an action to the user. For example:

 <ProgressBar x:Name="progressBar1" Value="50" Width="100"/>

20. Progress Ring

The animated progress control. For example:

 <ProgressRing x:Name="progressRing1" IsActive="True"/>

Conclusion

Here are some common controls as well as some new controls to design Windows Store applications. I hope you like this article. In the next article we will see some styling for our Windows Store applications.
 

COMMENT USING

Trending up