Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 136749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:59:51+00:00 2026-05-11T06:59:51+00:00

I am a bit surprised that while learning WPF/XAML/Silverlight almost all of the XAML/C#

  • 0

I am a bit surprised that while learning WPF/XAML/Silverlight almost all of the XAML/C# examples I have encountered have the ‘Click’ events in the XAML and very few in the Window or Page constructor.

With all the emphasis these days on ‘non-intrusive Javascript’, I would think that more developers would actually be structuring their XAML/code-behind like this:

XAML:

<Grid>     <Button x:Name='btnEdit'/> </Grid> 

Code behind:

public Window1() {     InitializeComponent();      btnEdit.Content = 'Edit';     btnEdit.Click += new RoutedEventHandler(btnEdit_Click); }  private void btnEdit_Click(object sender, RoutedEventArgs e) {     btnEdit.Content = 'This button was clicked.'; } 

Any thoughts on why this would be a good or bad practice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:59:52+00:00Added an answer on May 11, 2026 at 6:59 am

    Most of the smaller WPF examples give just an impression what is possible without focusing on design issues or good style.

    In real world applications XAML should only be used for declarative programming. For example, binding a command to a button or declaring a data binding. Karl Shifflett has some great articles about the MVVM pattern which separates the concerns of your WPF/Silverlight application very well.

    Code behind is in my opinion just suitable for tiny applications. It tends to mix view, control and data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have googled for it but I am a bit surprised that I couldn't
Bit support question. Apologies for that. I have an application linked with GNU readline.
While playing with different sort algorithms I was surprised that Groovy closures were performing
I have some old code written in C for 16-bit using Borland C++ that
I'm a bit surprised that it's so complicated to get a charset of a
I'm a bit surprised that it's so complicated to get a charset of a
I'm new to SVG and a bit surprised that this example is cropped and
I was a bit surprised a few minutes ago when I tried to overload
I'm a bit surprised to find the results of the following code, where I
I'm a bit surprised by Python's extensive use of 'magic methods'. For example, in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.