Pages

Wednesday, 22 August 2012

WinRT/Xaml/AKA Metro DataTemplate selection based on Data Types


You may have noticed that WinRT does not have automatic resolution of a DataTemplate based on the data type of object added to an ItemsControl. While unfortunate as this behavior is quite handy, it’s not too difficult to replicate the functionality using a DataTemplateSelector.

WPF for example, could do something like this:

<DataTemplate DataType="{x:Type local:Task}">
  <StackPanel>
    <TextBlock Text="{Binding Path=TaskName}" />
    <TextBlock Text="{Binding Path=Description}"/>
    <TextBlock Text="{Binding Path=Priority}"/>
  </StackPanel>
</DataTemplate>

When the Task type as shown above was found in a list, it would have been rendered as a StackPanel with three TextBlocks automatically. That rocked.

Read full article here

Testing Windows 8 apps using Visual Studio 2012


Testing Windows 8 apps using Visual Studio 2012

As we continue to innovate on the operating system platform with Windows 8, we also enhanced the toolset available in Visual Studio to increase your productivity in testing your Windows 8 apps. Ensuring a top notch quality of your app in this new modern OS environment through thoughtful design and testing will help increase the success of your app. In a previous blog post on Testing Metro style apps in Windows 8, we highlighted some of the key areas you need to take into account for building a high quality Windows 8 app. In this post, we explore a few capabilities in Visual Studio 2012 that will make the testing and verification of your app easier.

Read full article here

Windows Store-apps: WinRT XAML vs. Silverlight XAML


Last weekend I’ve finished the XAML-chapter of my upcoming book about developing Windows Store-apps with XAML and C#. I want to share the things that you should know about the WinRT XAML – the way I call it here – if you’re familiar with Silverlight or WPF.
The WinRT XAML is much like the XAML we know from Silverlight. But there are some differences in WinRT XAML:
  • the way you use your custom namespaces is different
  • there are some missing things (TypeConverters, Custom MarkupExtensions)
Let’s look at the two parts

Read full article here

Using SVG with Windows 8 HTML/JavaScript apps


Using SVG with Windows 8 HTML/JavaScript apps A common scenario when building a touch interface is having a particular UI element that you want to scale seamlessly between different screen sizes.  This is different than having the layout scale.  When scaling a layout, you make sure that content appears in roughly the same place, or in an optimized layout for a given screen real estate.  What I am talking about here is you have a particular interactive element that needs to scale according to screen size.   If you have a simple need, like scaling a logo, you can find examples of how to do that here.

An example would help illustrate what I am talking about.  Imagine I am making a basketball application and I want to allow users to tap an on-screen basketball court to track where shots are taken.  An example of what I am talking about is shown to the right.  My screen layout will be dependent on the court.  The bigger the screen, the bigger the court.  Using SVG is a great way to solve this problem.

Read full article here

Windows 8 and HTML Part 6: Displaying Data with WinJS ListView

Windows 8 and HTML Part 5: Fetch Data with WinJS

Windows 8 and HTML Part 1: Simple Example

Finally, we will start to get some data and begin building our application.  Based on Part 4, the logical place to start will be in home.js.  In the ready function for the page, we will use WinJS.xhr() to make an Http request to Twitter, and parse the results.  Making a call using WinJS.xhr() is straightforward in this case. 

WinJS.xhr({ url: "http://search.twitter.com/search.json?q=%23windows8&rpp=100" })

As you can see, we pass on object with the url property set to the Twitter search service.  We will search on the #Windows8 hash tag and request 100 tweets.  If we left this code as shown, our app would make a request to Twitter, but we would never get the results returned.  Why?  WinJS.xhr() is an async operation and will execute on a different thread than the UI thread that called it.  This is accomplished by using a Promise.  If you look at the xhr() return value, you will see that it actually returns a Promise.

To get the results when the Promise completes is async op, we need to call it’s then() or done() function.  You can chain multiple then() functions, because then() returns a promise. You cannot chain more than one done() method, because it returns undefined.  Since we want to parse the results of our search, we would write

WinJS.xhr({ url: "http://search.twitter.com/search.json?q=%23windows8&rpp=100" }).then(
   function(response) {},
   function (error) {},
   function (progress) {}
);

Read full article here

Windows 8 and HTML Part 4: First Taste of WinJS

Windows 8 and HTML Part 1: Simple Example

Let’s switch back to a WinJS application and take a look at what happens when a page is loaded.  Open package.appxmanifest and switch the Start Page back to default.html.

If you remember from Part 1, we created this application as a single-page style application.  This means that default.html gets loaded once, and different pieces of HTML content are then loaded “into” default.html for rendering and execution.  If we look at default.html, we see two important things.

Windows 8 and HTML Part 4: First Taste of WinJS First, we see that default.html loads the core script files for the WinJS framework and then the default.js script file (where we put our code), and also navigator.js, which helps navigate from page to page (with page really being HTML content being loaded into default.html).  The second thing to notice is that default.html contains a single div that is marked as aPageControlNavigator control.  It is this div that serves as the content host for the rest of the content.

Read full article here

Creating A RadCartesianChart – Line Graph


Creating A RadCartesianChart – Line Graph In this post, I will explore creating a line chart using the RadCartesianChart from the Telerik Windows 8 UI Controls.  You can Download Telerik Widows 8 Controls here.

Figure 1 shows the chart we wish to build. This is a linear chart built with a RadCartesianChart. It represents revenue for the last six months of 2012.

Read full article here

Web Informer Button