Marc Clifton wrote:1. It seems ridiculous to put the event wire-up in the code-behind when in my opinion, I would think XAML should be able to handle the wire-up declaratively.
I agree - it should, but it doesn't in many cases. So many folk write their own event-to-command handlers and the like to add that functionality. I personally don't like the approach of having heavy framework code to support something that should be simple out-of-the-box.
Marc Clifton wrote:2. I don't want the functionality in the Page's code-behind because I have functionality that is common to all pages but needs to be wired up to each button on the page.
Buttons are different - buttons support commands so you can bind a button to a command, no problems, in your Xaml
Marc Clifton wrote:3. It's ridiculous to me to write a code-behind handler in each page for each button that then calls some common code elsewhere -- why can't I just wire up the event in the XAML?
As mentioned, for Buttons you can, but not for all events. So 9for example) a double-click on some gui element will need 'something' in addition to out-of-the-box xaml.
Marc Clifton wrote:4. Clearly I can wire-up the event in the code-behind, why would I be restricted from doing exactly the same thing declaratively in the XAML?
Because the developers in MS didn't implement the functionality - I don't know of any underlying problem that would stop you being able to do this - after all, there are lots of 'tricks' ot there to effectively give you this functionality.
Marc Clifton wrote:So far, doing this one simple thing, it appears I have stumbled across a serious XAML inadequacy. Is that correct?
Marc Clifton wrote:(And please, don't go on about MVVM and all that rot -- there are many scenarios where MVVM is not the right approach, and I happen to be dealing with one of them.)
I wouldn't dream of it Regardless as to whether you are using MVVM or spaghetti-hoop code, it would seem remarkably sensible for XAML to support event-to-DataContextMethod out of the box.
Incidentally (& I'm thinking out loud) you could have a base View class possibly, with the event handler in there which your many XAML views could use? (i'd have a play myself, but I'm not in front of my Windows dev environment right now.
MVVM # - I did it My Way
Man, you're a god.
- walterhevedeich 26/05/2011
(That's an 'M')