Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Don't Want to specify Events in XAML
Message
De
02/09/2009 00:53:36
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Titre:
Don't Want to specify Events in XAML
Divers
Thread ID:
01422261
Message ID:
01422261
Vues:
120
OK,now that I've got lots of free time on my hands, I thought I'd spend it learning WPF.

Please tell me that there's a way to specify the the event handlers from the property sheet, such that it can go in the code and not in the XAML!!

I have some Mouse event and if it's specified in the XAML, it looks like this (and you can see these event handlers listed in the Property Sheet when using the designer):
      <Canvas Grid.Column="1" Margin="0" Name="paintCanvas" 
         Background="White" MouseMove="paintCanvas_MouseMove" 
         MouseLeftButtonDown="paintCanvas_MouseLeftButtonDown" 
         MouseLeftButtonUp="paintCanvas_MouseLeftButtonUp" 
         MouseRightButtonDown="paintCanvas_MouseRightButtonDown"
         MouseRightButtonUp="paintCanvas_MouseRightButtonUp"/>
Now, color me silly, but I don't really believe that this stuff belongs in the XAML!

So, as an experiment, I removed the MouseMove from the above, and defined it in the xaml.cs file, in the constructor. It works fine, as I expected it would. But, when looking at the property sheet when in the designer, the MouseMove event does not show the paintCanvas_MouseMove event handler, it's empty. Well, ok, I can even live with that, because it's the same behavior as in a WinForm Form or UserControl if I set up the event handler myself instead of through the designer. No biggie.

*But*, if I try to specify any eventhandler from the Property Sheet, it insists on putting it in the XAML ... is there a setting somewhere in VS where I can specify that I'd prefer this get put in the code instead of in the XAML?

TIA,
~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform