I'm developing a WPF app using MVVM. Most of my views have only xaml markup and nothing (except default boilerplate) on code behind.
All except one view that I use adorners to "blacken" the screen with when I want to disable the whole screen.
private void Window_Loaded(object sender, RoutedEventArgs e)
{
//todo: transfer to modelview
contentAreaAdorner = AdornerLayer.GetAdornerLayer(contentArea);
waitingAdorner = new WaitingAdorner(contentArea);
}
Is that ok? Or is there a better way to implement this in my viewmodel?
Reducing code-behind is a benefit of MVVM, not the goal.
The purpose of MVVM is to make UI logic simpler and more testable. Would your code be simpler and more testable if you moved this method to your view model? Very probably not; in fact it might be less so. So don't worry about it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With