The ViewModel class:
class MyViewModel : ViewModelBase, INotifyPropertyChanged
{
public string SomeText { get{...} set {...}}
public AnyNonMVVMControl MyControl { get {...} set {...}}
...
}
The Window XAML:
<Grid>
...
<TextBlock Text="{Binding SomeText}" />
<??? Content="{Binding MyControl}" /> <!-- how to bind MyControl to the View? -->
...
</Grid>
Assign the Model
...
window.DataContext = new MyViewModel(...);
...
I have a Control, which isn´t designed for MVVM. Rendering and Data are strongly coupled (bad design solution). I have this control in my viewmodel and want to bind it to my window. But I don´t want to add the Control directly in the XAML, because this control contains also business logic and data -> I need to access it in the viewmodel for performing actions.
So, how to “add” the control via Bindings to the window?
Use
ContentPresenterorContentControl: