Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 4 and Visual Studio 2010 > BOOK: WPF Programmer's Reference: Windows Presentation Foundation with C# 2010 and .NET 4
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: WPF Programmer's Reference: Windows Presentation Foundation with C# 2010 and .NET 4
This is the forum to discuss the Wrox book WPF Programmer's Reference: Windows Presentation Foundation with C# 2010 and .NET 4 by ; ISBN: 9780470477229
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: WPF Programmer's Reference: Windows Presentation Foundation with C# 2010 and .NET 4 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 31st, 2010, 04:43 AM
Registered User
 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Example ImageTriggers - Implementation in XAML vs. Implementation in C#

I'm completely new to WPF. While studying the ImageTriggers-example in chapter 13, I was wondering, in which case it makes sense to implement events in XAML, and in which case it's better to implement them in the C#-Code. (For example, in the ImageTriggers-example, you could also implement the behaviour in the .xaml.cs- File instead of the .xaml-File.)

Is there any rule, when to make event-implementations in code and when in xaml?

Last edited by Skyshaper; August 31st, 2010 at 07:36 AM.
Reply With Quote
  #2 (permalink)  
Old August 31st, 2010, 09:31 AM
Rod Stephens's Avatar
Wrox Author
Points: 3,141, Level: 23
Points: 3,141, Level: 23 Points: 3,141, Level: 23 Points: 3,141, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 640
Thanks: 2
Thanked 96 Times in 95 Posts
Default

I think Microsoft would say that you should do as much in XAML as possible and leave the code-behind for the application-specific programming. The idea is that XAML is part of the user interface and the code-behind should be able to focus on the database, calculations, and whatever else the program is for.

Kind of like you shouldn't need to write code to draw TextBoxes in a normal Windows Forms program. Similarly code-behind shouldn't need to worry about animating control movements, opening Expanders, and changing background images.

But in the end I think you should do what you find least confusing. I try to use XAML for the user interface as long as it's reasonably understandable and use code-behind when the XAML code would be too hard to understand.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote
  #3 (permalink)  
Old September 6th, 2010, 04:09 AM
Registered User
 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your answer.

Quote:
Originally Posted by Rod Stephens View Post
But in the end I think you should do what you find least confusing. I try to use XAML for the user interface as long as it's reasonably understandable and use code-behind when the XAML code would be too hard to understand.
That sounds reasonable for me, too.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Implementation Errors jpatrick BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 0 August 16th, 2009 11:58 AM
callback implementation aranjan ASP.NET 2.0 Basics 1 August 20th, 2007 09:46 PM
jms implementation yanis97 J2EE 0 August 31st, 2006 04:29 AM
COM Implementation using VB6 haianoop Pro VB 6 0 December 28th, 2005 03:01 PM
c# implementation help cshanmuganathan ASP.NET 1.0 and 1.1 Basics 1 May 28th, 2005 12:08 AM



All times are GMT -4. The time now is 04:02 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.