Archive

Posts Tagged ‘WinRT’

Windows 8 DevCamp – Charlotte

August 31, 2012 Leave a comment

I am excited to be presenting September 8, here in Charlotte for the Windows 8 DevCamp!  It is going to jam packed with great content and information to get you up to speed for delivering excellent apps to the Windows app store.  Here is a quick snippet of what we are going to cover:

Windows 8 Overview and the Windows Store

Haven’t seen Windows 8 or know what it takes to get an app in the Windows Store? We’ll cover that here. Drink your coffee because this first session will dive quickly into Windows 8, the platform, the changes, and the Windows Store, allowing you to monetize applications in a number of ways from in app purchases to subscriptions to trials.

Cookbook I: Design Templates and Style

In this session, we’ll talk about the design principles for Windows Store applications — controls, color, typography, and general guidelines to follow to deliver the best user experiences. We’ll also dive into the development choices and tooling support available. We’ll begin with the built in templates and show how we can quickly scaffold a data-driven application called the Contoso Cookbook.

Cookbook II: Data, Contacts, and Settings

You’ve seen the Cookbook. But, how do we leverage data? How do we expose our data to allow users to search and share from the app? We’ll explore these options in this session, from storing data, retrieving data via a web service using an in app purchase, to implementing search and sharing contracts, we’ll look at the code that makes this possible. We’ll also show how to store data locally, as well as roam preferences that can follow a user automatically as they log in to different devices.

Cookbook III: Application Bar, Tiles and Notifications

We’ve got the Cookbook well under way; now it’s time to add some polish. We’ll look at using the app bar for common tasks, and spend time talking about leveraging “live tiles” to create an up-to-date, engaging tile for your application. We’ll also look at using Notifications, and how applications can run either background agents for various tasks, or be notified from a remote service using the Windows Notification Service.

Hands On: [Your App Here]

Now it’s your time. We’ll work in breakouts and 1:1 as necessary to get the tools and environment set up and provide guidance for building out your app. Have an app already underway? We can test, review and provide feedback against store certification requirements. As time permits, we’ll cover additional features, and talk further about the certification process. And if your app isn’t quite ready yet, that’s fine! We’re here to give you the kickstart to building your app, and we’ll be here to make sure it’s done by October 26th.

Be sure to register now as space is limited!  Look forward to seeing you there and having some great Windows 8 sessions!

Windows 8 and building Metro apps

November 23, 2011 2 comments

I had a great time speaking at the Charlotte Enterprise Developers Guild last night.

Here are the slides and code for the presentation I made on Windows 8 and building Metro applications. We had a great turnout!

Thanks to everyone who came out and have a great Thanksgiving….

Win 8 & Building Metro Apps

November 19, 2011 Leave a comment

I will be speaking this Tuesday, November 22 at the Charlotte Enterprise Developer’s Guild in Charlotte, NC on Windows 8 and Building Metro applications. I will also be doing the same presentation on Thursday, December 15 at the WNC Developers Guild in Asheville, NC.

Here is my presentation summary:

Microsoft introduced a lot of new tools and goodies at the Build Conference in September. Let’s take a look and see what Windows 8 is all about. We will examine what it means to be “Metro” as well as roll up our sleeves and see what it takes to build an application. We will take a look at the tooling support in Windows 8 by looking at the developer preview for Visual Studio 2011 and Expression Blend. Come out and see what it takes to develop an application in Windows 8.

Look forward to seeing you there!

INotifyPropertyChanged woes? Too much ceremony?

September 27, 2011 14 comments

One of the things that Sivlerlight, Windows Phone 7, Windows Presentation Foundation, and WinRT developers face is the issue of data binding. This is a powerful feature that XAML technologies give us out of the box but there is a painful pattern that you have to implement in any property in order to get two-way binding to work.

First, you must implement the INotifyPropertyChanged event. Next you need to go through all of your properties and make sure you call the OnPropertyChanged method that you have in your implementation. This is a pain and adds no value to the underlying structure of your object. The only reason we need this extra fluff is to support data binding.

Well, there is a better way. There are actually several solutions or products out on the market right now but I prefer one that is the least intrusive and expensive. Let me introduce you to the NotifyPropertyWeaver project.

Here is a sample of what your code has to look like in order to have your properties raise the PropertyChanged event properly:

public class Person : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    public string GivenNames { get; set; }
    public string FamilyName { get; set; }

    public string FullName
    {
        get
        {
            return string.Format("{0} {1}", GivenNames, FamilyName);
        }
    }
}

This is really nice in that you don’t have to worry about any scaffolding or ceremony to get your properties to behave the way you would expect them. It also keeps your domain very clean and tight in that the only real fluff that you are exposing is the PropertyChanged event.

Here is what your code looks like when you compile it:

public class Person : INotifyPropertyChanged
{

    public event PropertyChangedEventHandler PropertyChanged;

    string givenNames;
    public string GivenNames
    {
        get { return givenNames; }
        set
        {
            if (value != givenNames)
            {
                givenNames = value;
                OnPropertyChanged("GivenNames");
                OnPropertyChanged("FullName");
            }
        }
    }

    string familyName;
    public string FamilyName
    {
        get { return familyName; }
        set
        {
            if (value != familyName)
            {
                familyName = value;
                OnPropertyChanged("FamilyName");
                OnPropertyChanged("FullName");
            }
        }
    }

    public string FullName
    {
        get
        {
            return string.Format("{0} {1}", GivenNames, FamilyName);
        }
    }

    public virtual void OnPropertyChanged(string propertyName)
    {
        var propertyChanged = PropertyChanged;
        if (propertyChanged != null)
        {
            propertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

As you can see, this pattern is typically what you would have had to have done in the first place but this now happens during compilation. The cool thing about this is that you have less code to maintain.

You can also have your objects derive from a base class that has the PropertyChanged event defined and anything else that you may want to have exposed in your base. Your base class would look like the following:

public class ModelBase : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    // Common logic here ....
}

Your derived class would look like the following:

public class Person : ModelBase
{
    public string GivenNames { get; set; }
    public string FamilyName { get; set; }

    public string FullName
    {
        get
        {
            return string.Format("{0} {1}", GivenNames, FamilyName);
        }
    }
}

Finally, your source code would look like the following after it has been compiled:

public class Person : ModelBase
{
    string givenNames;
    public string GivenNames
    {
        get { return givenNames; }
        set
        {
            if (value != givenNames)
            {
                givenNames = value;
                base.OnPropertyChanged("GivenNames");
                base.OnPropertyChanged("FullName");
            }
        }
    }

    string familyName;
    public string FamilyName
    {
        get { return familyName; }
        set
        {
            if (value != familyName)
            {
                familyName = value;
                base.OnPropertyChanged("FamilyName");
                base.OnPropertyChanged("FullName");
            }
        }
    }

    public string FullName
    {
        get
        {
            return string.Format("{0} {1}", GivenNames, FamilyName);
        }
    }
}

This is really nice in that we did not have to do any extra work to get this functionality. It also finds any dependencies and makes sure that the OnPropertyChange method is called for them as well. We can see an example of this with the FullName property. It is readonly but it should still be updated whenever the GivenNames or FamilyName properties are changed.

One of the reasons why I like this solution so much is that it uses a convention to provide the IL weaving. You are not required to have any attributes over your class or properties to get this to work. I find the solution simple and elegant in its assumptions and it typically represents the ways we would end up coding the INotifyPropertyChanged interface any ways.

Another nice aspect to this project is that it already supports the following toolkits:

  • Caliburn.Micro
  • Caliburn
  • MvvmLight
  • Prism
  • Cinch
  • Windows Phone Essentials

You also have the flexibility to use custom Attirbutes to let the compiler know what to weave as well.  I personally, don’t like this since I want to keep my domain as clean as possible but it does give you a lot of flexibility.

In order to get this working for your project, you have several options.  You can either download and install a VSIX Package and have this capability ready for any of your Visual Studio projects.  Or, you can use NuGet and bring in the package on demand in the project that you need.

There are other solutions out there on the market.  The biggest one that comes to mind is PostSharp.  With PostSharp, you can do even more than weaving for the property changed event.  There is a free version with it as well but I didn’t see a single implementation that didn’t require an attribute.

I will be going over the power of PostSharp in a later post so that we can compare the goodness of both implementations.

Hope this helps…

Follow

Get every new post delivered to your Inbox.

Join 211 other followers