1
Reply

Using MVVM pattern, In front-end UI(View) designer was doing designing, who are taking responsibility of binding object?

Using MVVM pattern, In front-end UI(View) designer was doing designing, who are taking responsibility of binding object?

    🎯 So, who is responsible for binding the object (ViewModel) to the View?
    ✅ The Developer (or MVVM infrastructure) is responsible for setting the DataContext — not the UI Designer.
    The UI Designer designs the UI using XAML and defines the binding paths like:

    But these bindings won’t work unless the ViewModel is assigned to the View’s DataContext — and this is typically handled by the developer.

    🔧 How the Developer Sets the Binding (via DataContext):
    Option 1: Code-Behind (commonly used in smaller apps)

    public partial class MainWindow : Window
    {
    public MainWindow()
    {
    InitializeComponent();
    this.DataContext = new MainViewModel(); // 🔁 Binding happens here
    }
    }

    Option 2: ViewModelLocator (preferred in MVVM frameworks like Prism or MVVM Light)