Event handlers and VS2008-B2 WPF designer

by Andrej Tozon 18. August 2007 14:25

Not being able to easily create event handlers for controls' events in Visual Studio's WPF designer posed as a potential turn off and a show stopper for less experienced developers, trying out the early bits of different incarnations of WPF designers. Beta 2 of Visual Studio 2008 (pka "Orcas") adds significant improvement with this issue: to begin with - double clicking on user control in the designer will create the default event handler for that control, as we're used with Windows Forms. Adding other event handlers is done through XAML part of the designer:

Adding event handler

Selecting <New Event Handler> in the above example would create the following code:

private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
{

}

And to later navigate to that event handler, there's a context menu navigation option right under your fingers:

Context menu

The best part is that event handler creation isn't limited to single (selected) event handler. If you're starting with pre-created XAML file, and event handler names are already there, but without any generated code, just select all necessary controls and choose "Navigate to Event Handler" from the context menu and all missing handlers will be created for you. Without the actual implementation, of course; this one is still up to you :)

Tags:

WPF | Development

Comments

8/19/2007 5:12:18 PM #

Peter Kellner

thanks for the tip.  I sure hope they create an events window in the final release.

Peter Kellner | Reply

2/18/2008 3:08:25 PM #

Miral

The general strategy that seems to work with WPF is to use Blend to make up the basic structure of windows and then directly modify the XAML to make it actually work the way you want it to.

As people have already observed, the Intellisense in the VS2008 designer is pretty good, but just about everything else is completely useless.  Blend is better, but there's still things that you just can't do without directly modifying the XAML.

It really makes me wonder why on earth the tools fragmented in the first place -- why didn't the team doing Blend just fold all of that into the VS2008 designer?  Why make a separate product?

Miral | Reply

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading





Andrej Tozon

MVP - Client Application Developer

Microsoft Certified Solution Developer

MSN Alerts

View Andrej Tozon's profile on LinkedIn

Subscribe to me on FriendFeed

Andrej Tozon's Facebook profile

Get help from Andrej Tozon!

RecentComments

Comment RSS