Silverlight Brass Tacks

Bill Reiss' Silverlight Ramblings

About the author

Author Name is someone.
E-mail me Send mail

Recent comments

Authors

Tags

Don't show

    Categories

    None


    Disclaimer

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

    © Copyright 2008

    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.

    Currently rated 2.0 by 2 people

    • Currently 2/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    Posted by Bill Reiss on Wednesday, April 23, 2008 7:54 AM
    Permalink | Comments (3) | Post RSSRSS comment feed

    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.

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    Posted by Bill Reiss on Wednesday, April 23, 2008 7:36 AM
    Permalink | Comments (0) | Post RSSRSS comment feed