Control-Level Modal Dialog

25 02 2009

In episode 115 of DNRTV, Billy Hollis shows off a great looking WPF application. It has a number of unique UI features, but one in particular which I loved was the control-level “modal dialog”.

Back at the time, I hacked up a class that would give me the same effect. I’ve had numerous requests for this code on StackOverflow, and I thought appropriate that I get the sample somewhere public. I’ve since integrated it into a product, and while I can’t release that updated source, I can release the original version.

This uses some code from Josh Smith’s Dragging Elements in Canvas CodeProject article

Download here! Note that you must rename the file from DialogPresenterzip.doc to DialogPresenter.zip (stupid limitation of WordPress).

An initial list of features that I wanted to add were:

  – Center the child window on the canvas
  – Add resizing capability
  – Add Dialog Templating
  – Add some styling (as you will see, the dialog looks ugly)

Enjoy!





How to Frustrate Me Less…

28 06 2007

Rob Relyea posted a reply to my “What’s Hot and What’s Not” post asking:

We’d love feedback on how to frustrate you less…”

I appreciate Rob asking the question. I feel the WPF team and growing community seem to be doing a pretty good job at reducing the frustration levels. One of my biggest frustrations (which is also common with many new technologies) was succinctly expressed (albeit tongue-in-cheek) by Kevin Moore:

“In Windows Forms, there are two ways to do everything: a good way and a bad way. In WPF, there are ten ways to do everything: two that are amazing, 3 that are good, 1 that is bad, and 4 that suck.”

It’s distinguishing the 2 amazing solutions which is so challenging. So how do we get there?

The first way is by example. Production quality applications, with source code, like Vertigo’s Family.Show are fantastic learning tools. It would be impossible to produce many of these, however I’d love to see a WPF LOB application which focuses on common data entry processes.

Near-production level samples such as Kevin’s Bag-O-Tricks also make up some of the most useful resources I’ve used to reduce frustration.

What I’d love to see is some Open Source applications written in WPF. I am sure these will come with time. The gathering of like-minded people will produce an eco-system of best practices, innovative UI’s, and sample code.

I have had a few issues with MSDN help files. If you navigate to help files like IValueConverter.Convert, the example code seems to be missing. (Disclaimer: I haven’t looked deep into this issue – I’m not sure if it affects other help files). Also, I have a problem with my installed MSDN Library that came with Orcas Beta 1. This problem has been description here, and here; but this issue is understandable – Orcas is beta software.

Other than that, the continued support on the MSDN Forums goes a long way to resolving those niggling problems one may be having.

How else do we find those 2 amazing solutions? I’m not exactly sure at this point..

What has helped me to date?

Blogs, blogs, and more blogs. There is a wealth of information out there in blog-land. Tapping into this source is well worth it.

I’ve always learned by two methods: 1) looking at existing resources with a view to teach it to others; and 2) finding out the ‘Why?’. People (usually bloggers or MSDN forum responders) who have a thorough understanding of the technology often have the answers to ‘Why?’, and consequently have helped me with a number of “Ah Ha!” moments.

These days, I don’t purchase many technical books (although I do have a Safari subscription). However, Adam Nathan’s Windows Presentation Foundation Unleashed and Chris Anderson’s Essential Windows Presentation Foundation are spectacular books; Adam’s book is packed with pragmatic advice to help you on the path to WPF “goodness”; while Chris Anderson gives unique insights into the architectural decisions behind the technology – which is invaluable.

What I hope to do via this blog is add some of my knowledge to the base that is growing on the web. Stay tuned for my first set of articles..  





XAML Not Compiling?

17 06 2007

Are your XAML files not being compiled when you press F5 in Visual Studio? If so, read on… 

This weekend I managed to get Visual Studio Orcas 2008 Beta 1 installed on a Vista VPC (It only took 4 attempts for a total of 24GB downloaded – ouch! Don’t even get me started on how the MSDN help doesn’t work!).

Recently I’ve been building a WPF application whom’s sole purpose was for me to learn WPF. I decided to keep on with that project with Orcas. However, I’ve learnt a lot since I first started this WPF in Visual Studio 2005, so I created a new solution and built up some of the app. This way, I could implement all the stuff I’d learnt across the entire application.

I ran into troubles when I included some of the VS2005 XAML files into the project. Whenever I changed the pure XAML and ran the solution, the changes were not added to the binary. Now it doesn’t take long to build this app, so I wasn’t realizing that it wasn’t building at all when I pressed F5.

So after some experimentation, I found that I was missing an entry for one of the properties of XAML file. The highlighted section shows what to check:

XAML_FileProperties

After I added the MSBuild:Compile directive to the “Custom Tool” property, everything worked as it should!

HTH!

 P.S. Apart from my MSDN help problem, Visual Studio Orcas 2008 Beta 1 runs much better than I expected. I hope this is a sign of things to come!





WPF Marketing

2 06 2007

I can’t help but feel that Microsoft got the marketing for WPF wrong.

I believe Microsoft’s first mistake was renaming the technology. The dreary “Windows Presentation Foundation” name still seems terrible compared to the inspiring “Avalon” codename. I think Microsoft may have learnt their lesson from the uproar that followed; in fact in one of their latest offerings, they renamed the awkward “WPF/E” to a much cooler “Silverlight”. While “WPF” is finally starting to roll off the tongue, I’d still prefer to be able to discuss this fantastic technology with a name that at least hints at its mystique.

WPF (and the .NET Framework 3.0) was released  with the flurry of releases that came with Vista’s launch. At that time, there was some discontent in the community to the value of Vista over the stable and performing XP. I recall a lot of material out on the web that said WPF would allow the developer to take advantage of Vista’s capabilities. In fact, on the back cover of the Microsoft Press published book, “Applications = Code + Markup” by Charles Petzold, there is the statement:

…giving you the skills you need to exploit new interface and graphics capabilities for Windows Vista.

Now I’ve used WPF for a while now, and there is nothing in WPF that is Vista specific. In fact, it’s a bit of a pain to use Vista features like “glass” and the new Message Box dialog – you need to go back to unmanaged code. Granted, certain UI Elements are rendered faster on Vista that previous operating systems, but this isn’t a functional difference. 

So why is that a problem? Well, there is a feeling out there with some developers that WPF is a Vista-only technology. WPF runs perfectly ok on Windows XP and Server 2003. I had to clarify prove that Windows Server 2003 could run WPF apps to a number of other members on my team.  I can only assume this will hurt take-up of the technology.

I also feel Microsoft missed the boat with it’s promotion of the technology to one very large group developers – the ones that build data-orientated systems. WPF doesn’t ship with an equivalent control to Windows Forms DataGridView. I understand that there are deadlines, etc, and that some controls just didn’t have time to be shipped. But, the DataGridView is such a fundamental control to Windows Forms developers who build data-orientated applications. Yes, WPF shipped with a very capable ListView control, which can be moulded into a  data grid, but it does take work. Not only that, there seemed to be very few samples which used WPF to bind to relational data sources. Unfortunately, I had a number of conversations with developers who shunned WPF because they felt the data binding capabilities of WPF were lacking. There was probably too much focus on the 3D spinning video inside a button which was rotated 65 degrees. As most people know who have spent any time with WPF, one of the really fantastic features of the technology is its databinding. It pains me to go back to WinForms for my normal day job after the pleasure of using WPF data binding.

I really want to congratulate the huge team that worked on WPF. I’ve never had so much fun building rich Windows User Interfaces. I just hope the technology hasn’t been long-term hampered by the marketing.