Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Builds and modernizes Windows-only WPF applications on .NET, covering XAML, data binding, commands, threading, and .NET Framework migration.
Use this skill ↓59% 59%0 ptsof test cases passed
Passed 13 of 22 test cases with the skill, and 13 of 22 without it.
3 of 3 safety checks passed
Problem: Business logic in XAML code-behind files makes testing difficult and creates tight coupling.
// WRONG: Logic in code-behind
public partial class CustomerWindow : Window
{
private readonly CustomerService _service = new();
public CustomerWindow()
{
InitializeComponent();
}
private async void SaveButton_Click(object sender, RoutedEventArgs e)
{
// Business logic should not be here
if (string.IsNullOrEmpty(NameTextBox.Text))
{
MessageBox.Show("Name is required");
return;
}
var customer = new Customer { Name = NameTextBox.Text };
await _service.SaveAsync(customer);
CustomerList.Items.Add(customer);
}
}
Solution: Move logic to ViewModel with commands.
// CORRECT: Logic in ViewModel
public partial class CustomerViewModel : ObservableObject
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.