How to bind from XAML to ModelView with IOC and not using static datacontext in Modelview

PharmaSoft 1 Reputation point
2023-09-05T16:59:10.33+00:00

Hello

How to bind from XAML to ModelView with IOC and not using static datacontext in Modelview

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,475 questions
{count} votes

2 answers

Sort by: Most helpful
  1. PharmaSoft 1 Reputation point
    2023-09-06T09:29:30.62+00:00

    Yes it is.

    I inject the IDabasecontext to the viewmodel but the view in XAML create a new viewmodel through behavior and if I dont make a static Idatacontext in my viewmodel after injection, it will be null from the view creation .

    I think I missing somethig ?

    Thanks a lot for help, I cannot find a different to do that

    0 comments No comments

  2. PharmaSoft 1 Reputation point
    2023-09-06T22:38:45.4066667+00:00

    I found the solution.

    In fact, my anderstanding of IOC was not good. I forget to inject the viewmodel ion the view so the view create another viewmodel

    Thanks to scaffold the datacontext, I coud inject only in mainwindows and the datas follow. wonderfull