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 (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)



Visual Studio 2008 Beta 2

28 07 2007

Tonight I installed Visual Studio 2008 Beta 2 on a fresh Virtual PC.

While I have only touched the surface of using the product, I do have these initial impressions:

  1. I love the new “Organize Usings” menu option. I’m a bit of a neat freak when it comes to my code, and this will save a bunch of time. I don’t recall seeing it in Beta 1, so I’m assuming this is new…
  2. I’m thankful that the WPF designer now remembers if you last have XAML or Designer view open, when you re-open the solution.
  3. Unless I’m missing a setting somewhere, it seems as though xml elements are not automatically “closed-off” when editing XAML by hand. This is annoying, and makes manually editing XAML somewhat slower in VS2008 compared to VS2005. I wonder if someone could come up with a hack to fix this?

Overall, I’m really impressed! I’m looking forward to diving a bit deeper over the weekend…

Reflect Yourself

19 07 2007

I often dive into assemblies with Lutz Roeder’s Reflector program. I did something out of the norm today by opening up one of the dll’s the company I work for produced. It is a very large and complex dll, that hasn’t had the care and attention that it duly requires. The view from reflector showed up a number of issues that can easily be fixed.

Have you had a look at your assemblies via reflector?

P.s. If your doing WPF work, make sure you grab the  BamlViewer.

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..  

What’s Hot and What’s Not

28 06 2007

The field of IT is constantly changing. It takes a great deal of time outside of work to stay up with current technology. At various stages throughout my career, I’ve had to bet on what technologies will become “the next big thing”. Some successful guesses have been XML, .NET, and Web Services (in hindsight, these don’t seem like technologies that could have failed, but focusing on XML was a bit out-there, and .NET was a huge gamble). Some of my wrong guesses have been Linux (back in 1996 the market just wasn’t ready); low-level unix network programming; and to a certain extent WinForms1. I thought it might be interesting to write down what technologies I am currently focusing my learning efforts on. Then, sometime in the future, it will be interesting to see how my bets have turned out.

  ThumbsUp WPF
    I just love using WPF. It makes developing a pleasure again. Granted, it can still be frustrating; but it’s usually logically frustrating.
  ThumbsUp XAML
    XAML looks like a great investment of my time. Not only does it power WPF, it is also used for Silverlight, WF, and various other technologies.
    WiX is an open source installer toolkit. This is a much better way to build installation packages compared to the tool included with Visual Studio.
    There is a lot more to ClickOnce than meets the eye. This technology used to deploy a WPF app, with a WiX installation program for the server-side is a great, maintainable deployment model.
  ThumbsUp Silverlight
    The technology to reboot the web“. There is a lot of hype around Silverlight. I am only scratching the surface, but I’m hoping it will live up to my already lofty expectations.
  ThumbsDown ASP.NET Ajax
    I’m amazed at what people are doing with javascript. However, this is getting less focus from me a this point.
  ThumbsDown CSS
    Likewise, CSS is a technology I am passionate about. But, I’m focusing more on other technologies at the moment.
  ThumbsDown WinForms
    While I’m a little disenchanted with WinForms, it is still currently my greatest area of expertise. I will continue to spend time keeping right up-to-date on advancements; especially in the CAB arena (we use the CAB in projects at work).
  ThumbsUp WCF
    I made a heavy investment into Web Services. I haven’t had the opportunity to use WCF much as yet; this is something that is going to change.

So, I wonder if I’m betting on the right things now? I could probably change focus and move to a web-orientated technology-set, but for some reason I just love developing high quality windows applications. WPF is my technology of choice.

1 – WinForms has put food on the table for a number of years now, so it wasn’t a bad bet; it’s just that the web is going through its 2.0 bubble. It will be interesting to see how things pan out.

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:


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


 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.