Click here to Skip to main content
15,867,686 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
Pete O'Hanlon2-Feb-14 11:27
subeditorPete O'Hanlon2-Feb-14 11:27 
GeneralRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
Marc Clifton5-Feb-14 15:09
mvaMarc Clifton5-Feb-14 15:09 
GeneralRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
Pete O'Hanlon5-Feb-14 23:15
subeditorPete O'Hanlon5-Feb-14 23:15 
AnswerRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
_Maxxx_2-Feb-14 19:19
professional_Maxxx_2-Feb-14 19:19 
GeneralRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
Mycroft Holmes3-Feb-14 3:05
professionalMycroft Holmes3-Feb-14 3:05 
GeneralRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
_Maxxx_3-Feb-14 9:29
professional_Maxxx_3-Feb-14 9:29 
GeneralRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
Marc Clifton5-Feb-14 15:13
mvaMarc Clifton5-Feb-14 15:13 
GeneralRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
_Maxxx_5-Feb-14 15:26
professional_Maxxx_5-Feb-14 15:26 
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?


IMHO yes.


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 Smile | :) 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

.\\axxx
(That's an 'M')

QuestionHow do I wire Command to functions not in the view? Pin
Marc Clifton2-Feb-14 10:14
mvaMarc Clifton2-Feb-14 10:14 
QuestionHow to bind a dataset to a WPF richtextbox? Pin
fsunole0329-Jan-14 10:43
fsunole0329-Jan-14 10:43 
AnswerRe: How to bind a dataset to a WPF richtextbox? Pin
Wayne Gaylard30-Jan-14 1:07
professionalWayne Gaylard30-Jan-14 1:07 
QuestionHandling RowEditEnding in a DataGrid according to MVVM pattern Pin
Piotr Z27-Jan-14 23:43
Piotr Z27-Jan-14 23:43 
AnswerRe: Handling RowEditEnding in a DataGrid according to MVVM pattern Pin
Pete O'Hanlon28-Jan-14 0:29
subeditorPete O'Hanlon28-Jan-14 0:29 
GeneralRe: Handling RowEditEnding in a DataGrid according to MVVM pattern Pin
Piotr Z28-Jan-14 0:51
Piotr Z28-Jan-14 0:51 
GeneralRe: Handling RowEditEnding in a DataGrid according to MVVM pattern Pin
Pete O'Hanlon28-Jan-14 1:10
subeditorPete O'Hanlon28-Jan-14 1:10 
AnswerRe: Handling RowEditEnding in a DataGrid according to MVVM pattern Pin
_Maxxx_2-Feb-14 19:36
professional_Maxxx_2-Feb-14 19:36 
QuestionProblems updating datagrid from collection Pin
abollmeyer23-Jan-14 10:55
abollmeyer23-Jan-14 10:55 
AnswerRe: Problems updating datagrid from collection Pin
Mycroft Holmes23-Jan-14 12:04
professionalMycroft Holmes23-Jan-14 12:04 
QuestionBinding property from XML file data Pin
abollmeyer21-Jan-14 9:18
abollmeyer21-Jan-14 9:18 
AnswerRe: Binding property from XML file data Pin
abollmeyer21-Jan-14 14:44
abollmeyer21-Jan-14 14:44 
QuestionCombobox / Textblock field Pin
eddieangel21-Jan-14 6:24
eddieangel21-Jan-14 6:24 
AnswerRe: Combobox / Textblock field Pin
Jason Gleim21-Jan-14 7:52
professionalJason Gleim21-Jan-14 7:52 
GeneralRe: Combobox / Textblock field Pin
eddieangel21-Jan-14 8:07
eddieangel21-Jan-14 8:07 
GeneralRe: Combobox / Textblock field Pin
Jason Gleim21-Jan-14 8:48
professionalJason Gleim21-Jan-14 8:48 
GeneralRe: Combobox / Textblock field Pin
eddieangel21-Jan-14 9:14
eddieangel21-Jan-14 9:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.