A Custom Storyboard Component in Xaml

In WPF & Silverlight, a Storyboard is a collection of animations running in parallel.  Not everyone likes the name “Storyboard” though.  The idea behind the name was that that list of timelines running in parallel are like a list of plot lines in the plan for a movie. In any case, just like you can…

0

Implementing SelectedValue with the Silverlight ComboBox

Here’s the scenario … You have a Customers collection and an Orders collection.  In the Orders collection, an Order has a CustomerID property; this is the key to an item in the Customers collection.  Your goal is a ComboBox that updates the CustomerID property of a Customer, but interacts with the end user in terms…

10

An ICommand with IsEnabled

ICommand is a simple interface with three members – Execute, CanExecute, and CanExecuteChanged (more on those here).  You can write your own implementations of that interface, one for each command, but that gets a bit heavyweight.  So there are several implementations of ICommand that are pluggable and re-usable, like DelegateCommand, RelayCommand, and RoutedCommand.   One…

5

A master/detail view with navigation

I don’t remember what got me thinking about it, but somewhere along the line I wanted a master/detail view with a navigation bar.  E.g., when you change selection in the master view, you can navigate back to the previous selection.  Here’s an example (here my selection started on “Wilma”, then I changed it to “Fred”,…

3

A Comparable DataTrigger

Property triggers today only check for equality.  We’d like to add support for other comparison operators, but that hasn’t happened yet.  But I needed them for a project, and wrote a workaround for it.  It’s a bit hacky in a couple of places, but if you can get past that, it’s a handy way to…

7

Binding to anonymous types in an Xbap or Silverlight application

It’s easy to use Linq queries to create objects, and to use {Binding}s to bind properties of those objects into your view.  If you’re doing this for an application that will run as an Xbap (“WPF Browser Application”) or as a Silverlight app, just note that you need to generate nominal types rather than anonymous…

5

Simple way to create a gradient brush in Xaml

  Rob, Nikhil & I were talking today about the early days of Xaml when you could create linear gradient brushes as an attribute value.  E.g. (borrowing from Rob’s post on this subject) instead of creating a LinearGradientBrush for the fill of a rectangle with this Xaml: <Rectangle Width=”300″ Height=”200″ >     <Rectangle.Fill>         <LinearGradientBrush>…

1

A Context-Sensitive Help Provider in Wpf

Here’s an example of a way to add context-sensitive help to your application.  The main idea is to simply use the built-in ApplicationCommands.Help command.  This command is already tied to the F1 key, and so executes when you hit F1, and tells your command handler what element the user was on when it was hit….

20

Building read-only objects in Xaml

We often use Xaml to instantiate and initialize objects.  For example, given “<Foo Bar=’1’/>”, a Xaml loader creates a Foo object, and sets the Bar property to 1.  That works when the Bar property is settable, but what can you do if it isn’t?   An example of this scenario in .Net today shows up…

1

Two ProgressBar Tricks

Here’s a couple of handy ProgressBar tricks …   The first trick is to use a negative Minimum value, so that as soon as a ProgressBar starts, you give the user the visual feel that the progress has already begun.  This is especially useful if, in your scenario, it takes a couple of seconds to…

4