views:

206

answers:

1

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 when I want to make the whole screen disabled.

    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?

+6  A: 

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.

Robert Rossney
Exactly what I thought, but being new to MVVM I wanted some opinions first. Thanks!
Padu Merloti