Share via


10 reasons to consider WPF for your next desktop application - Reason Number 1: Rich Content Model.

We're going to kick off the technical articles for this blog with the first part in an ‘oldie but goodie’ series from Josh Twist called ‘10 reasons you should consider WPF for your next desktop application’ which is still relevant a year on. WPF is a great platform for writing any application, here's the 1st reason of 10 why.

Reason Number 1. Rich Content Model

Earlier I introduced a series of posts entitled 10 reasons to consider WPF for your next desktop application. If you haven't read the intro yet, better head on back and read it first.

For sometime web developers have become accustomed to easily creating the content they want to see using HTML but this power has been out of reach for WinForms developers. For example:

Want a button with some different types of formatted text? No can do. Want a tooltip to have a picture inside? No can do*.

With WPF this is about as easy as it gets.

Reason 1: Rich Content Model

<Button>
<Button.ToolTip>
<StackPanel Orientation="Horizontal">
<Image Source="/bruusi.jpg" Margin="3"/>
<TextBlock>
<Run FontWeight="Bold">Tooltips</Run>
<LineBreak/>
What about tooltips with pictures and formatting!
</TextBlock>
</StackPanel>
</Button.ToolTip>
<TextBlock>Look a <Run FontWeight="Bold">button</Run> with
<Run FontStyle="Oblique">formatting!</TextBlock>
</Button>

A simple example but hopefully it indicates just how dramatically easy it is to do this in WPF and allows you to see some of the possibilities. The world really is your lobster. Furthermore, every piece of this could have been sourced using WPF's powerful databinding - more to come on that later.

Wanna see this sample in action? Try it here: Reason 1: ClickOnce Sample.

PS - I will make the full source available for all the examples at the end of the series.

* - One for nitpicker's corner. I realise that it is *possible* to do this in Windows Forms, but it is also pretty tough!

  • Next: Reason 2. Databinding.  

Originally posted on 11th October 2007 by Josh Twist here.

Comments