The future of Windows Presentation Foundation (WPF) and what’s coming next

In 2006 I started working with the first preview versions of the Windows Presentation Foundation with my Trivadis fellow Christoph Pletz. We wrote 2007 the very first German article about MVVM and 2008 I published my first book with the title “Windows Presentation Foundation – the ultimate handbook”. (more…)
Read more...

It’s there: Windows Store Apps with XAML and C#– the ultimate handbook

Wow, it’s done. The ultimate handbook about Windows Store Apps with XAML and C# is printed and available. You can order your copy of the German-written 1146-pages-book on amazon: Amazon.de: Windows Store Apps – das umfassende Handbuch Find more information about the book on amazon, on my homepage http://www.thomasclaudiushuber.com/windowsstoreapps and on the publisher’s website on www.galileocomputing.de/3196.

Training on Windows Store Apps

In Germany, Switzerland and Austria I’ll give a three-day-training on Windows Store Apps. If you or your company have interest on this professional training, directly contact me via http://www.thomasclaudiushuber.com/contact.php. It is possible to train you in the Trivadis-Trainings centers or onsite at your office. So far so good, let’s look at the past and the future

The past

Puh, this was year was really instensive. Here the straight plan I had so far:
  • January: Buy new home
  • February: My second daughter Sara was born.
  • March: Finish the manuscript for the book
  • April:Renovate and improve new home (thanks to Makita Zwinkerndes Smiley)
  • May: Move
  • … in all months: Working as a consultant and trainer @Trivadis.

The future

So the future contains much more spare time, it’s necessary, because I say “Time is money is not true, time is unpayable”. I want to spend as much as I can with my kids, my wife, family and friends (See also this awesome post from Tim on that topic). So the future plan looks like this:
  • June: Finish a WPF-project as a consultant and enjoy the free weekends
  • July: Parental leave Smiley
  • August: Parental leave Smiley
  • September: Back to work, speaking at basta (www.basta.net) and at Trivadis-internal TechEvent
Keep on rockin’ Thomas
Read more...

Dragging Elements in Windows Store Apps

In Windows Store Apps there are three kinds of Touch-Events:
  • Gesture Events – those are high-level-events like Tapped or RightTapped.
  • Pointer-Events – low-level-events like PointerPressed, PointerMoved, PointerReleased.
  • Manipulation-Events – low-level-events for multi-touch actions like rotate, scale or transform an element.
Pointer-Events consolidate Touch-, Pen- and Mouse-Input. So on the UIElement-class from WinRT you wont find Mouse-Events known from WPF/Silverlight like MouseLeftButtonDown. In my upcoming Windows Store Apps I want to show how Elements can be dragged/moved with Pointer-Events. You can download the code of the sample here: MovingElements, or in German ElementeVerschieben-Sample The app looks like below. By touching an empty space in the yellow area, an Image is inserted. The image can be grabbed with a finger or with the mouse-cursor and moved around. The app works also with multiple fingers. You can grab multiple images at once and move them around. MovingElementsWinRT If you´ve feedback to the code, feel free to comment. Smiley  As I´m really busy the next weeks/months with the writing of the Windows Store Apps-book, I´m not able to give you big support on the code. Use it or not. Thomas
Read more...

Windows Presentation Foundatoin 4.5 – WPF 4.5 – the 3rd edition is here

I’m proud to announce that the ultimate handbook about Windows Presentation Foundation (WPF) in .NET 4.5 is in stores now. Order your copy of the German-Speaking Topseller about WPF directly here on Amazon: Order WPF-Book on Amazon.de Find all the Details about the book on www.thomasclaudiushuber.com/wpf Currently I’m working really hard on my book about Windows Store Apps. It’ll be released next year and can already be preordered on Amazon: Preorder Windows Store Apps-Book on Amazon.de So maybe I’ll blog more again in the future. But for now I’m totally focused on finishing the Windows Store Aps-book. So far so good, stay tuned, Thomas
Read more...

Windows Store-apps: WinRT XAML vs. Silverlight XAML

This post is part of a series about creating Windows Store-apps with XAML and C#. Find the Content of the series here: Windows Store-apps with XAML and C# blog-series 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

Use custom namespaces

There are two ways in XAML to use a namespace:
  • 1:1-Namespace-Mapping
  • 1:n-Namespace-Mapping
Read the difference for both in Silverlight- and WinRT-XAML below.

The 1:1-Namespace-Mapping

Let’s assume you’ve the following class:
namespace UIRocker.Special
{
  public class WindowsEight
  {
    public bool IsGreat { get; set; }
  }
}
To use this class in Silverlight-XAML, you’ve to add an Namespace-Mapping like this
xmlns:rocker="clr-namespace:UIRocker.Special"
or like this if the CLR-Namespace is in another assembly than the XAML-file containing the Namespace-Mapping below: 
xmlns:rocker="clr-namespace:UIRocker.Special; assembly=UIRockerLib"
With the Namespace-Mapping the classes from that Namespaces can be used with the chosen alias. The alias is “rocker” in the snippets above, so the WindowsEight-class can be used as below:
<rocker:WindowsEight IsGreat="True"/>
In WinRT-XAML you’re using the class in the same way as above, but the way of creating the Namespace-Mapping is different. Instead of using the syntax with “clr-namespace…” you use:
xmlns:rocker="using:UIRocker.Special"
You don’t care if the Namespace UIRocker.Special is in another assembly as the XAML-file or not. This works exactly the same way as the using-directive in C#, where you also don’t care if the Namespace is in another assembly than the .cs-File or not. So, great improvement, but creates a little incompability with Silverlight-XAML.

The 1:n-Namespace-Mapping with XmlnsDefinition-Attribute

The Namespace-Mappings above have been 1:1-Mappings. One XML-Namespace was mapped to one Silverlight/WinRT-Namespace. In Silverlight-XAML you can create a 1:n-Namespace-Mapping by placing the XmlnsDefinitionAttribute (Namespace: System.Windows.Markup) on your assemblies like this:
[assembly: XmlnsDefinition(
 "http://thomasclaudiushuber.com/","UIRocker.Special")]
[assembly: XmlnsDefinition(
  "http://thomasclaudiushuber.com/", "UIRocker.Mvvm")]
Classes out of the Namespaces UIRocker.Special and UIRocker.Mvvm can be used in XAML with one alias by making a 1:n-Namespace-Mapping like this:
xmlns:rocker="http://thomasclaudiushuber.com/"
Unfortunately in WinRT-XAML there is no possibility for a 1:n-Mapping. The Namespace Windows.UI.Xaml.Markup contains a XmlnsDefinition, but it’s not an attribute, it’s a struct and therefore not usable. Especially when you create a library with many Namespaces in it, it’s great to use just one alias for the library in XAML. Maybe the next Version of WinRT will contain such a mapping. By the way, first versions of Silverlight also didn’t support 1:n-Namespace-Mappings.

Missing things in WinRT-XAML

There are a few other things that are not in WinRT-XAML or behave differently. Let’s take a look at them.

Typeconverters

As XAML is XML, every Attribute contains a string-value. This string-value needs to be converted into the value of the property-type the attribute represents. For primitive types like double, float, int, bool, char etc., the conversion automatically is done by the XAML-Parser (Silverlight and WinRT). Also for Properties of type enum, the XAML-Parser tries to convert the specified string-value into the enum-type of the property. There is also a conversion for some central types hardcoded in the XAML-Parser of Silverlight and WinRT, e.g. the Brush-Type. This conversion allows you to assign a string in XAML where a Brush-Instance is required:
<ListBox Background="Red">
The XAML-Parser takes the “Red”-string, creates a SolidColorBrush with the Color Red and assigns it to the Background-property of the ListBox. (Excourse to WPF-XAML: In WPF-XAML this conversion is not done by the XAML-Parser, it is done by the BrushConverter-class) Now if you have properties that are of your own type, let’s look at this works in Silverlight and WinRT. Let’s assume we have the classes below:
public class Person
{
  public Address Address { get; set; }
}
public class Address
{
  public string City { get; set; }
  public string Country { get; set; }
}
In Silverlight-XAML, it is possible to create a Person-instance as below if a TypeConverter for the Address-type exists:
<local:Person Address="Müllheim Germany"/>
The corresponding typeconverter could look like this:
public class AddressConverter : TypeConverter
{
  public override bool CanConvertFrom(...Type sourceType)
  {
    if (sourceType == typeof(string))
      return true;
    return base.CanConvertFrom(context, sourceType);
  }
  public override object ConvertFrom(...object value)
  {
    if (value != null && value is string)
    {
      var array = value.ToString().Split(' ');
      if (array.Length != 2)
        throw new ArgumentOutOfRangeException(
          "Invalid format for address");
      return new Address
      {
        City = array[0],
        Country = array[0]
      };
    }
    return base.ConvertFrom(value);
  }
}
The only thing that is additionally required is to tell the XAML-Parser where to find the AddressConverter. You do this by specifying the TypeConverterAttribute either on the Address-Property in the Person-class or on the Address-class itself. Below an example that specifies it on the Address-class.
public class Person
{
  public Address Address { get; set; }
}
[TypeConverter(typeof(AddressConverter))]
public class Address
{
  public string City { get; set; }
  public string Country { get; set; }
}
So far to Silverlight-XAML, now let’s look at WinRT-XAML. As mentioned above, WinRT-XAML also supports conversion for
  • primitive Types like bool, char, double, int, float,…
  • enumeration-values
  • central types like e.g. the Brush-type.
If you’ve custom types like the Address-class, currently there’s no support. There’s no TypeConverter in WinRT. Dot.

Markup-Extensions

In Silverlight-XAML it’s possible to create custom subclasses from MarkupExtension and use them in XAML with curly braces. WinRT doesn’t support custom Markup-Extensions. Dot. Did you find out other bigger differences about XAML? See you next week with the next post about WinRT and Windows Store-apps. Thomas
Read more...

What’s coming next? XAML, WinRT, HTML5,…

It has been really quiet for a long long time on this blog. I've had many amazing projects in the past half year. All about Windows Presentation Foundation. In my sparetime I focused on the HTML5-part, because I'm very interested in the development of mobile apps. I've also looked at the HTML5-part in WinRT. I've published an article about developing Metro-Apps with HTML5/JavaScript in a special edition JavaScript-magazine (German). You can order it here: http://javascript-spezial.de/ Later this year I had talks at conferences in Germany (BASTA!) and in Switzerland (Trivadis TechEvent) about Windows Phone, WinRT, Silverlight, HTML5. What's coming next:
  • series of blog-posts about Modern UI-Style Apps with XAML and C# (will start in about two weeks)
  • some WinRT-articles for the German Windows Developer magazine
  • some talks at BASTA! and TechEvent in September. And maybe on other conferences
  • Upgrading WPF-book to .NET 4.5
  • Writing a new book about developing Windows 8 Modern UI-Style Apps with XAML and C#. Will be available next year.
So stay tuned! Thomas
Read more...

WPF book has been released and Silverlight book will be available on 28th of August

Exactly two years after the first release of the WPF-book the second edition is available since some days. Find more details about the content and where you can order it on http://www.thomasclaudiushuber.com/wpf. The Silverlight-Book has also been written and is currently running through the process of reading, testing and printing. It will be in stores on 28th of August. Find more information about the Silverlight-Book and where you can order it on http://www.thomasclaudiushuber.com/silverlight. I hope you like the books and you can master the “programming-challenge” of your wpf- and silverlight-projects with the knowhow you got from the books. Cheers, Thomas
Read more...

Friday-Evening Fun with Silverlight’s Animation Easing Functions

This weekend I’ve to finish the second edition of my WPF-book. Luckily it’s going to rain tomorrow. But I’ve almost done it. This evening I’ve just ported a small sample for Animation Easing Functions from WPF to Silverlight. It was easy, all I had to do was using a PathGeometry instead of the not existing StreamGeometry to draw the lines of the functions. Use the fun-sample below to play around with these easing functions. You’ll get the code of this version with my upcoming german Silverlight-Book in August. So have fun, Cheers Thomas.
Read more...

Visual Studio has been released, Silverlight 4 has been released and the books are on their way…

After Visual Studio has been released on Monday this week, Silverlight 4 is also available since Thursday. I’ll have to speed up my book-writing. As many of you know, I’m writing on a second edition of my WPF-book to .NET 4.0 and Visual Studio 2010. I’m also writing on a Silverlight-book (about Silverlight 4.0). Below some details of the two books. The WPF-Book: I’ll finish the update of my WPF-book till end of April, so it’ll be released in June. There are many new things in it, like a section to the Model-View-ViewModel-Pattern, Multitouch, the new Controls DatePicker, Calendar and DataGrid, Animation Easing-Functions, VisualStateManager, Windows 7 Taskbarintegration, Pixel-Shaders and much more. Of course there’s also a new version of the FriendStorage-Application that is using new features and controls, like e.g. the DataGrid: 01_06 FriendStorage now also has integration into the Windows 7 Taskbar. So you can iterate through the friends via the Buttons shown in the Windows 7 Taskbar Thumbnail. Also recognize that the image of the current friend is also displayed as overlay-image on the Taskbar-Button image  You find the second edition of my WPF-book here on amazon.de The Silverlight-book I’ll write on the Silverlight-book till end of June, so it’ll be released in August. I hope you’re looking forward to it. I gave and will give my best that it’s a great resource to all professional Silverlight-Developers and those who want to become one of those. In May I’ll show the contents of the Silverlight-book on my homepage. I’ll also blog here. For now I can say that there’s a FriendStorageOnline-Application in the Samples with Login/Registration and CRUD-Operations via WCF Ria Services. A logged-in User can create Friendlists and insert data as usual. The app looks like this: 01_04 The Silverlight-book is also already on amazon here. But keep in mind that there could be a change in pages (some more up to 1000) and so maybe also in price. I’ll post more information about the targeted pagecount in May, then you’ll also see some details of the contents. Ciao, Thomas
Read more...