Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Create New Form in WPF Sample #2094


User avatar
0
behiunforgiven created

In WPF Sample there is only one form. How can I create another form and use dependency injection ?

for example:

private readonly IPersonAppService _personAppService;

        public MainForm(IPersonAppService personAppService)
        {
            _personAppService = personAppService;
            InitializeComponent();
        }

how can I create a new MainForm(and showdialog) ?


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can create forms similar to MainForm. You need to derive your forms from Form and ITransientDependency.

    When you want oto create a new form, get it from dependency injection like this. var form = IocManager.Instance.IocContainer.Resolve<YourNewFormForm>();