Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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..
 
Old August 31st, 2010, 09:31 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
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!)
 
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.





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 04:01 PM
c# implementation help cshanmuganathan ASP.NET 1.0 and 1.1 Basics 1 May 28th, 2005 12:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.