(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .

Windows 8 Development + Blendability

(3 votes)
Braulio Diez
>
Braulio Diez
Joined Dec 14, 2009
Articles:   7
Comments:   3
More Articles
2 comments   /   posted on Nov 15, 2012
Tags:   windows-8 , braulio-diez
Categories:   Data Binding , Windows 8 , Design
Tweet

Introduction

Expression Blend is a “black unknown tool” for many XAML developers. Many geeks (including myself) tended to say things like “Hey ! I’m happy just coding XAML”, “This is for graphic designers”, “It doesn’t generate clean code”.

In this video article we are going to try to demystify this tool for developers, we will learn some basic features that will show us how we can boost our productivity. As a vehicle to explain the concepts and techniques here exposed we are going to write from scratch the following dummy puzzle app:

 

Video: Win8 Puzzle App - Intro

 

Takeaways from this article:

  • How to create your UI using Expression Blend without having to manually code a single line of XAML.
  • How to assign data binding via properties tab (no more typo-bug when adding a binding).
  • How to display sample data to allow you fine tune your layout without having to run the app to check the visual aspect.
  • How to drop controls and customize them (ListView + GridView).
  • How to visually create and customize controls templates.
  • How to assign Converters via properties.

 

Step 1 – Creating the App + Display the list of pieces

 

In this step we will check how we can apply data binding and display sample data in design mode. We will start by creating the project, and adding a list with the pieces of the puzzle.

We are going to follow the next steps:

  1. Create the project (we will use Visual Studio, we are geeks).
  2. Create an entity that will identify a puzzle piece.
  3. Create a ViewModel that will hold the list of pieces (we will add to it more properties and methods in later steps).
  4. Drop a List View.
  5. Assign Data Context… plus Design Data Context
  6. Apply Data Binding to a control.
  7. Modify items template.
  8. Apply Data Binding to a control template.
  9. Run the app same results as design.

 

Video: Win8 Puzzle App - CreatingProjectListView

 

Step 2 – Adding a canvas to build the puzzle

We are going to learn how to customize a GridView using the properties panel and define custom templates. In order to setup the puzzle canvas, we will drop a GridView control, establish the right size and aspect and setup the data binding.

Note: a GridView won’t be the ideal control to be used for a Puzzle Canvas, but I have rather chosen it to get us familiar with this standard control (the goal of the article is to let us learn about Win 8 + Blendability).

We are going to follow the next steps:

  1. Add the plumbing in the ViewModel to hold the puzzle canvas info.
  2. Drop a GridView.
  3. Configure Items container to hold a 2x2 pieces canvas.
  4. Configure the Items Template to be binded to a single puzzle slot + binding.

 

Video: Win8 Puzzle App - PuzzleCanvas

 

Step 3 – Drag & Drop Behavior

 

One cool feature that we get when we develop  a Windows 8 app it’s the “AllowDrop” “CanDragItems” properties that are already included into the controls. In this snippet we will setup the drag & drop operations for different combinations of controls (puzzle list  >> puzzle canvas, puzzle canvas >> puzzle list view, puzzle canvas >> puzzle canvas).

We are going to follow the next steps:

  1. Create the ViewModel methods to update the puzzle canvas and pieces bucket.
  2. Add Names for the controls (some code in the view going on).
  3. Setup Drag & Drop list view.
  4. Setup Drag & Drop elements of the GridView.
  5. Drag from the Piece’s available list into the puzzle canvas.

 

Video: Win8 Puzzle App - Drag and Drop #1

 

Dragging and Dropping other cases

  1. Drag & Drop puzzle canvas to puzzle canvas.
  2. Drag & Drop puzzle canvas to piece’s list view

 

Video: Win8 Puzzle App - Drag and Drop #2

 

Step 4 – Notifications, Converters & Blend

 

In this final step, we will learn how automatically refresh the user interface when a property changes (via INotifyPropertyChange), and how to apply a converter without having to type a single line of code. We will add a boolean property that will notify the user interface when the puzzle has been solved ad we will map the original viewModel property value from bool to visibility (display or hide a textblock).

we are going to follow the next steps:

  1. ViewModel, create a function to check if the puzzle is solved and expose it via property.
  2. INotify Property Changed plumbing.
  3. Adding a Textbox to notify the user… Visibility to Bool?
  4. Adding a converter, assigning it via properties.

 

Video: Win8 Puzzle App - Converters

 

Summary

 

In this article we have learnt how we developers can take benefit of using Expression Blend, letting us design our user interface by dragging and dropping and having available test data in design mode. Most of the topics covered in this article can be applied to the newest Visual Studio 2012 IDE as well.


Subscribe

Comments

  • mahaveer

    Re: Windows 8 Development + Blendability


    posted by mahaveer on Mar 21, 2013 17:41

    can u tell that how to create launch icon in windows phone app in c#?

  • mahaveer

    Re: Windows 8 Development + Blendability


    posted by mahaveer on Mar 21, 2013 17:42
    can anyone tell me that how to create launch icon in windows 8 phone app in c#?

Add Comment

Login to comment:
  *      *       

From this series