Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Adorner break MVVM?

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?

like image 690
Padu Merloti Avatar asked Mar 24 '10 04:03

Padu Merloti


1 Answers

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.

like image 171
Robert Rossney Avatar answered Nov 11 '22 08:11

Robert Rossney