A Caliburn.Micro recipe: filters « Marco Amendola

August 10, 2010 in Silverlight, WPF

image

Extension to Caliburn.Micro to allow implementation of filters similar to what is found in Caliburn.

A Caliburn.Micro recipe: filters « Marco Amendola

Visual Studio Project Template for Caliburn.Micro WP7

August 10, 2010 in Windows Phone 7

Two days ago, Rob Eisenberg released a sample of Caliburn.Micro for Windows Phone 7.  I spent a few minutes today creating a Windows Phone 7 Caliburn.Micro project template for Visual Studio 2010 from that project.  It should help you get started more quickly on your WP7 projects.

Download and copy the Caliburn.Micro.WP7.zip file to the following directory on your computer: \Documents\Visual Studio 2010\Templates\ProjectTemplates\Silverlight for Windows Phone

Start up Visual Studio and create a new project.  You will see an option for Caliburn.Micro (WP7):

image

After the project is created, you will see the following project structure:

image

Fix the reference to Caliburn.Micro (download from CodePlex), set a breakpoint in the constructor of MainPageViewModel, and run the application.  You will see that when navigation happens to MainPage, that MainPageViewModel is created. 

Continue execution to view the app in the emulator:

image

I like Rob’s idea of doing View-first for pages and ViewModel-first for components on a Page.  I have chosen the following naming: MyPage/MyPageViewModel (pages) and MyView/MyViewModel (user controls).

WP7 UI Pattern: Pivot Views

August 4, 2010 in Windows Phone 7

image

The user is shown multiple views of the same item side by side using the Pivot control. The buttons on the Application Bar remain consistent across Pivot pages.

Example: E-mail (all, unread, urgent, flagged); Appointment (details, attendees)

(video)

WP7 UI Pattern: Layered Panorama

August 4, 2010 in Windows Phone 7

image

The user is presented with a panorama containing multiple pages of content. The first is a list that acts as a menu. Clicking on a list items takes you to another panorama with the specific content. The Application Bar is not used.

Example: AP Mobile

(video)

Summary: UI Design & Interaction Guide for Windows Phone 7

August 2, 2010 in Design, Windows Phone 7

image 

The July 2010 release of the UI Design and Interaction Guide for Windows Phone 7 is a document that all designers and developers of Windows Phone 7 applications need to become thoroughly familiar with.  It is a beautifully laid out 101-page document that discussed the phone’s capabilities, controls, and interactions.  As I read the guide, I took notes that I could refer to quickly as needed.  The result is a 10-page summary of the UI Design & Interaction Guide for Windows Phone 7.  I hope others find it useful.

MVVM with Caliburn.Micro

July 30, 2010 in Silverlight, Windows Phone 7

Silverlight, WPF, and Windows Phone 7 developers should consider using the Model-View-ViewModel (MVVM) pattern for developing their LOB applications.  One choice for MVVM is Caliburn.Micro developed by Rob Eisenberg.

 

Here is a link to the documentation topics:

  • Recipes
    • SimpleContainer

 

I know Rob has been working on some WP7 goodness that should be out soon.  Looking forward to the release.

Summary of Windows Phone 7 Application Certification Requirements

July 28, 2010 in Windows Phone 7

 

image

Updated for Version 1.3 released September 2010.

After going through the Windows Phone 7 Application Certification Requirements document, I created this summary of the main points for quicker reference than the 27 pages of the September 2010, version 1.3 document.

Size:

· Over the air install up to 20MB;

· disclose additional data package if greater than 50MB;

· max XAP size 400MB;

Images:

Description Pixels File Type Required Location
Application Icon 62 x 62 PNG Required XAP
Application Tile Image 173 x 173 PNG Required XAP
Device application icon 99 x 99 small173 x 173 large PNG, 262 dpi Required Marketplace catalog
Desktop application icon 200 x 200 PNG, 262 dpi Required Marketplace catalog
Panoramic background art 1000 x 800 PNG, 262 dpi Optional Marketplace
Screenshot 480 x 800 PNG 1-8 Required Marketplace catalog

Performance:

· First screen render within 5 seconds (use splash screen)

· Responsive to user input within 20 seconds

Prompt User:

· Chat, instant messaging, or other person-to-person communication applications that all creation of accounts via phone device, must verify that user is at least 13 years old

· “Opt-in” consent for publishing personal information to any service or other person

· “Opt-in” consent for push notifications

· User-friendly error message on exception

· Visual progress bar with cancel option for time consuming activities

· Back button in games to present in-game pause menu or main menu with resume option

· Message if Location Service turned off in a location-aware application

· Explicit permission on first use of toast or tile notification

· Explicit permission on first run of application under a locked screen

· Apps that play their own background music must ask before stopping or adjusting music playback from Music + Video Hub

Settings screen:

· Enable/disable toast notification

· Enable/disable tile notification

· Enable/disable application from running under a locked screen

· Use/Override music from Music + Video hub

· Control own background music/adjust hub music (ex: volume)

Restrictions:

· May not require the user to pay outside of Windows Phone Marketplace to activate, unlock, upgrade, or extend usage of the application

· May not sell, link to, or promote mobile plans

· May not consist of, distribute, link to, or incent users to download, or otherwise promote alternate marketplaces for applications and/or games

· Must not jeopardize the security or functionality of phone devices or Marketplace

· Advertising must comply with http://advertising.microsoft.com/creative-specs

· Apps that allow purchase of music content must include Windows Phone music Marketplace as an option.

· For music not purchased through Windows Phone music Marketplace, app must include its own playback

· Content restrictions include: licensed, copyrighted, illegal, obscene, indecent, violent, defamatory, libelous, slanderous, threatening, hate speech, discriminatory, adult-related, promotes illegal activities, excessive alcohol, tobacco, weapons, drugs, violence, profanity

· PInvoke, COM interoperability, debug symbols, reflection were it affects phone capabilities, uncaught exceptions

· Must not include viruses, malware, or malicious software

Review: Infragistics UX Training for Software Professionals

July 26, 2010 in Design

image

I had the opportunity to take the course, Engineering the User Experience – Essentials for Software Professionals, from Infragistics using the online on-demand option.  The course has the following objectives:

  • Understand, communicate, and apply the background and concept of user experience.
  • Assess the user experience of interactive products.
  • Apply UI design best practices to their own work.
  • Understand the process of user experience and how to merge it within their development process.
  • Understand the role and power of user interface controls and patterns.

The course is presented online via Silverlight, takes approximately 3 hours to complete, and costs $395.  For a limited time, when you purchase a NetAdvantage product this course is included for free.

The first part of the training defines User Experience (UX) as including usability and appeal and states the case of why UX is important.  More content is this area would have been useful.

Read the rest of this entry →

52 Weeks to a Pragmatic Programmer: Challenge 2

June 21, 2010 in Pragmatic Programmer

Take Responsibility

Tip 3 in The Pragmatic Programmer states:

Provide Options, Don’t Make Lame Excuses

For one day keep track of what you say in meetings, on the phone, or through e-mail and categorize them as:

  • Reasonable option/solution
  • Lame excuse

You don’t have to share your list, but blog/comment about the experience.

Infragistics XamWebOutlookBar & Caliburn

June 14, 2010 in Silverlight

Last week I set out to build a simple Caliburn sample that included the Infragistics Silverlight XamWebOutlookBar.  I made progress and got to a point where Rob Eisenberg was able to help me get the rest of the way.  The approach I was taking was trying to figure out what conventions I should add to get Caliburn to recognize the XamWebOutlookBar.  Rob’s answer was that not everything needs to be a convention.

When you run the application, you will see the XamWebOutlookBar hosted in a sidebar.  Both groups shown in the OutlookBar have corresponding ViewModels that in turn have associated Views:

image

At the end of the article is a link to the project source code.  In order to get the project to compile, you will need to download the Infragistics assemblies and add references to the following:

image

A trial of Infragistics can be downloaded from here.

Here is the final project structure:

image

Application

In typical Caliburn style, the App.xaml has been changed to a CaliburnApplication:

<cal:CaliburnApplication xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
             xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
             xmlns:cal="clr-namespace:Caliburn.PresentationFramework.ApplicationModel;assembly=Caliburn.PresentationFramework"
             x:Class="InfragisticsCaliburn.App">
    <Application.Resources>
    </Application.Resources>
</cal:CaliburnApplication>

In App.xaml.cs, we setup MEF as the container and the use MEF to find the ShellViewModel:

protected override IServiceLocator CreateContainer()
{
    return new MEFAdapter(CompositionHost.Initialize(new AssemblyCatalog(Assembly.GetExecutingAssembly())));
}

protected override object CreateRootModel()
{
    var shell = ServiceLocator.Current.GetInstance<IShell>();

    if (IsRunningOutOfBrowser && HasElevatedPermissions)
        MainWindow.Closing += (s, args) => { args.Cancel = !ServiceLocator.Current.GetInstance<IShell>().CanShutdown(); };

    return shell;
}

ViewModels

MEF is able to find ShellViewModel in the container using the IShell type because it implements IShell and Exports itself as IShell:

[Export(typeof(IShell))]
public class ShellViewModel : ScreenConductor<IScreen>, IShell
{
    private readonly MainViewModel _firstScreen;

    [ImportingConstructor]
    public ShellViewModel(MainViewModel firstScreen)
    {
        _firstScreen = firstScreen;
    }

    protected override void OnInitialize()
    {
        this.OpenScreen(_firstScreen);
    }

}

Because of the ImportingConstructor attribute, an instance of MainViewModel is created.  The class is implemented as:

[Export(typeof(MainViewModel))]
public class MainViewModel : ScreenConductor<ISidebarItem>.WithCollection.OneScreenActive
{
    [ImportingConstructor]
    public MainViewModel([ImportMany] IEnumerable<ISidebarItem> sidebars)
    {
        Screens.AddRange(sidebars);
        this.OpenScreen(Screens.First());
    }
}

For the XamWebOutlookBar implementation, the important thing to note is that MainViewModel is setup as a ScreenConductor that manages ISidebarItem instances where only one sidebar screen is active at a time.  The ImportingConstructor attribute then finds all items registered in the MEF container as ISidebarItem.

In this example, both ContentAViewAModel and ContentBViewModel are similar:

[Export(typeof(ISidebarItem))]
public class ContentAViewModel : Screen, ISidebarItem
{
    string message = "ContentA is working";

    public ContentAViewModel()
    {
        DisplayName = "Content A Header";
    }

    public string Message
    {
        get { return message; }
        set
        {
            message = value;
            NotifyOfPropertyChange(() => Message);
        }
    }

    public string Icon
    {
        get { return @"../../Images/briefcase2.png"; }
    }
}

Each of the ViewModels export themselves as ISidebarItem, inherit from Screen, and implement ISidebarItem.

Views

In MainView.xaml, the DisplayName and Icon properties are used to render the group’s header and icon:

<igOB:XamWebOutlookBar x:Name="sidebarOutlookBar" 
        MinimizedWidth="35" AllowMinimized="True" 
        NavigationPaneMinimized="sidebarOutlookBar_NavigationPaneMinimized"
        NavigationPaneExpanding="sidebarOutlookBar_NavigationPaneExpanding"
        VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
        GroupsSource="{Binding Screens}">
    <igOB:XamWebOutlookBar.GroupContentTemplate>
        <DataTemplate>
            <ContentControl cal:View.Model="{Binding}" />
        </DataTemplate>
    </igOB:XamWebOutlookBar.GroupContentTemplate>
    <igOB:XamWebOutlookBar.GroupHeaderTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding DisplayName}" />
        </DataTemplate>
    </igOB:XamWebOutlookBar.GroupHeaderTemplate>
    <igOB:XamWebOutlookBar.DefaultLargeIconTemplate>
        <DataTemplate>
            <Image Source="{Binding Icon, Converter={StaticResource stringToImageSourceConverter}}"/>
        </DataTemplate>
    </igOB:XamWebOutlookBar.DefaultLargeIconTemplate>
    <igOB:XamWebOutlookBar.DefaultSmallIconTemplate>
        <DataTemplate>
            <Image Source="{Binding Icon, Converter={StaticResource stringToImageSourceConverter}}"/>
        </DataTemplate>
    </igOB:XamWebOutlookBar.DefaultSmallIconTemplate>
</igOB:XamWebOutlookBar>

Notice the GroupsSource property is bound to the Screens property that the ViewModel inherits from its base class.  The ContentControl for each group is set to the ViewModel representing the group.  The group header is bound to the DisplayName property and the small and large icons are set to the Icon property.

The Message property is bound in the View for the group content:

<UserControl x:Class="InfragisticsCaliburn.Views.ContentAView"
    xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
    xmlns:xhttp://schemas.microsoft.com/winfx/2006/xaml
    xmlns:d=http://schemas.microsoft.com/expression/blend/2008
    xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <Grid x:Name="LayoutRoot" Background="White">
        <TextBlock x:Name ="Message"/>
    </Grid>
</UserControl>

Download the source of the project here.