Archive for October 2008

Composite Silverlight 2.0 Application Library Updated to RTW

I’ve updated my demo of the Composite Silverlight Library I built to work with Silverlight RTW.  The P&P group has plans to ship the next version of the PRISM library (PRISM 2.0) that supports Silverlight, so I’ve started to use their bits instead of the ones that I built with this sample.  Bellow is a screenshot of the conversion.  As you can see, the default styles in Silverlight 2.0 have been changed, and the rendering is much better.

Download:  CompositeSilverlightRTW.zip

Composite Silverlight (PRISM) Region Quickstart

We Are Experiencing Technical Difficulties

I’m in the middle of trying to update my life to Silverlight RC0. Starting in a week or so, I’ll be trying to update my samples to RC0 and I’ll be creating new Silverlight samples in RC0.

I’m putting the color picker control on hold until after PDC so that everyone is on the same Silverlight page.

Thank you for your patience.

Silverlight 2 Resources Browser (works with RC0)

David Anson has put up a pretty cool application for looking at the default templates for Silverlight 2 controls. It works with Silverlight 2 RC0, which was released just this last week.

This is pretty freaking awesome stuff for anyone doing design in Silverlight.  Go check it out.

A note: I would comment more about RC0 except that I’m doing alot of work with Silverlight that needs to be working with today’s plugins and it is my understanding that RC0 stuff may not work with the current plugin. If I’ve misunderstood, someone correct me please.

How To Use a ListView or DataGrid In a ComboBox Drop Down (Without A Line Of Code)

Super cool new thing I learned today. In WPF, we can make it so that the drop down (popup) on a ComboBox displays the data in a ListView. Because of the fact that I believe the DataGrid will eventually overtake the ListView as the gold standard for data display in WPF, we’ll do it both ways.

This tutorial is done entirely in Blend and without a line of code.

Step 0) (for the DataGrid only)

Go to Code Plex and download the WPF Toolkit. Extract to a convenient location.

Right-Click on the References folder in your project tab and click “Add Reference…”

clip_image001

Navigate to the location you extracted the WPFToolkit.dll file, select it and hit OK.
clip_image001[6]

Step 1) Select the ComboBox you wish to change and edit the ControlTemplate by right-clicking and selecting “Edit Control Parts (Template) –> Edit a Copy…”

clip_image001[1]

Step 2) Find the ItemsPresenter. This is what would normally display our ItemsSource.

clip_image001[3]

We’re going to get rid of it. And the ScrollViewer for good measure.

Step 3) Where the ScrollViewer is, put in a ListView or a DataGrid, whichever one you’re using.

clip_image001[5]

Now, go the properties of that ListView or DataGrid and click on the box to the right of “ItemsSource”

clip_image001[11]

and, in the resulting menu, select “Template Binding –> ItemsSource”.

clip_image001[7]

Set the DataContext of the ListView or DataGrid to the DataContext of the parent ComboBox using the same process.

And… you’re done! Open the ComboBox and you will see that you can select items in the ListView or DataGrid in the ComboBox dropdown and see those items change the selection of the ComboBox.

clip_image001[13]

You’ll notice that this is probably not yet an ideal solution. For example, when we select an item, the dropdown doesn’t automatically close. Your best bet is to use the SelectionChanged event to trigger some logic to close the ComboBox dropdown.