Silverlight Brass Tacks

Bill Reiss' Silverlight Ramblings
My upcoming Silverlight book for beginners Hello! Silverlight 2 with Dave Campbell, available online now!



Pages

Recent posts

Navigation

Archive

Blogroll

Tampa Divorce Lawyer

North of Tampa in Lutz, Florida. A Tampa Divorce Lawyer focusing on family, divorce, and real estate law.

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Why would you specify an event handler in XAML instead of code?

Forgive me if I'm being dense and this was obvious to other people, but I have been wondering about this for while.

In most demos I see by the Silverlight Team and others, they typically declare the event handler in the XAML:

<Rectangle x:Name="rect" MouseEnter="rect_MouseEnter"/>

As a developer, it seems to me like this is a strange mix of code and design time stuff, and it would be cleaner to wire up the event handler in code, and then all of the event handling code is in one place.

I guess the key to this is that I am a developer, and that's how developers think. The problem with doing this in code is that designers then need you to change some code if they want to change the visual element that the MouseEnter event is wired to. If, however, the event handler is wired up in XAML, then the designer can move that event to some other element, and as long as the event handler code doesn't do anything specific to that particular element, it should all still work.

In this world of tighter integration in the designer-developer workflow, there will be a lot of little things like this that developers will need to get used to.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Posted: Apr 23 2008, 10:54 by Bill Reiss | Comments (11) RSS comment feed |
  • Currently 2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:

First Post for Silverlight Brass Tacks Blog

Hi, my name is Bill Reiss and I'm a Microsoft MVP focusing on Silverlight. You may have seen my other blog at http://www.silverlightgames101.net, and you may be wondering "why another blog?". Well I'd like to keep that one focused specifically on game development, and this will be more general Silverlight stuff. I've had some things I wanted to post about lately that were not game related, and it seemed like a better idea to keep things separate.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Posted: Apr 23 2008, 10:36 by Bill Reiss | Comments (1) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: