I want to change the view inside of a ContentControl based on an enum property in the ViewModel for the Window hosting these controls. Below are two sample UserControls:

<UserControl x:Class="View1">
        <Button />

<UserControl x:Class="View2">
        <TextBox />

Property in my viewmodel:

public StyleTypes StyleType { get; set; } //StyleTypes is an enum

And the window's content control:

<ContentControl />

Normally I would have a ViewModel related to each UserControl and have a DataTemplate to switch the view based on the selected viewmodel. But is it good practice to make an empty viewmodel for the two simple controls above when I'm just going to set their datacontext to the parent Window's context anyways?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.