Anything They Can Do Why can't you?

5Oct/090

Silverlight ComboBox Strong Typed Selected Object

For those of you that use Silverlight and the built in ComboBox here is something that works a little cleaner than the default casting of the SelectedItem on a ComboBox. I am a big fan of extension methods and I plan to post a lot about them in the future so I decided to start with something small.

public static T GetSelectedObject(this ComboBox cb) where T:class
{
    return cb.SelectedItem as T;
}
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.