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,755 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. 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

  3. 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


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.