Monthly Archive for October, 2006

New Camera (i’m all digital now!)

My new D80 has arrived!  I’m very excited to play with it (especially in Argentina, when I travel there during Thanksgiving).

I tried it out over the weekend.  Here are some shots from the Pike Place Market in Seattle.  (You can tell from the ambient greyness that it’s officially fall in the pacific northwest.)

 

Healthcare Application - Source Code Posted!

Source code for the Contoso Healthcare Application is now posted on the community site! (Thanks Karsten!)

This is a great app. (I demoed it at TechEd Southeast Asia & its been shown at many other events as well).  It showcases, among other things:

  1. 3D fliptransitions.  (This UX paradigm is similar to a doctor’s real world experience of flipping through a patient chart.)
  2. Data visualization on a 3D surface for fast comparison.
  3. Listbox styling dependent on level of information desired.
  4. Annotations on video.
  5. Patient diagnosis in flow document format.

Get the code here.

http://www.clearification.com

Check it out!  Hilarious new site called Clearification from comedian Demetri Martin. It’s in collaboration with Microsoft.  The site’s first episode is already posted.  :-)

Dynamic Styling - Detecting ResourceDictionaries at Site of Origin

Here’s an XBAP that dynamically grabs the “styles” available to it from site of origin.

Note: By “styles,” I mean distinct look & feels defined in different ResourceDictionary files, not simply the <Style> class.  You could also call these “themes.” 

The resulting proof of concept app looks like this:

The app contains a button whose look is determined by the ”style” selected in a combobox.  The list of available “styles” (xml file) and the associated ResourceDictionaries (xaml files) are kept up at the site of origin.  Right now, the “styles” available to the app are:

  1. Fish “style” (thanks to Fil Fortes)
  2. Shiny “style” (thanks to Robert Ingebretsen)
  3. KevinButton “style (thanks to Robert Ingebretsen and Kevin Moore)

You can grab the xbap code here.  Or you can run the RC1 XBAP

 

Implementation

The list of available styles are kept in Styles.xaml up at site of origin:

  <Styles>
     <Style
        Name=”fish”
        File=”pack://siteoforigin:,,,/Styles/Fish.xaml”/>
     <Style
        Name=”shiny”
        File=”pack://siteoforigin:,,,/Styles/Shiny.xaml”/>
     <Style
        Name=”kevinbutton”
        File=”pack://siteoforigin:,,,/Styles/KevinButton.xaml”/>
  </Styles>

 

In my Page1.xaml, I define a XmlDataProvider for that xml file, providing an XPath query that returns a collection of Style elements.  Note that I’m using the pack:// syntax to refer to the site of origin xml file.  Ashish Shetty has a great post about the pack:// concept.

  <Page.Resources>
    <ResourceDictionary>
      <XmlDataProvider
        Source=”pack://siteoforigin:,,,/Styles.xml”
        x:Key=”XmlStyles”
        XPath=”/Styles/Style”/>
    </ResourceDictionary>
  </Page.Resources>

 

Next, I bind my ComboBox to that XmlDataProvider.  I can use the DisplayMemberPath to easily set how visualize the items.  In this case, I want to show the value of the Name attribute.

  <ComboBox x:Name="StyleComboBox" 
    SelectionChanged=”OnSelectionChanged”
    ItemsSource=”{Binding Source={StaticResource XmlStyles}}” 
    DisplayMemberPath=”@Name”
    FontFamily=”Calibri, Verdana”
    Width=”90″
  />

Because the Resources property is not a DependencyProperty, I cannot bind to it.  Instead, I write a little bit of code to swap the Grid’s resource dictionary on selection changed:

  void OnSelectionChanged(object sender, RoutedEventArgs e)
  {
      XmlElement styleElement= (XmlElement) this.StyleComboBox.SelectedItem;
      String styleFile = (String) styleElement.Attributes["File"].Value;
      ResourceDictionary dictionary = new ResourceDictionary();
      dictionary.Source = new Uri(styleFile, UriKind.RelativeOrAbsolute);
      this.Grid.Resources = dictionary;
  } 

 

 The overall app architecture looks something like this:

Updated Samples for RC1

FYI: I’ve posted RC1 versions of most of my samples:

 

Note: all my loose XAML posts still work on RC1 :-)