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?