Why does Application.Current == null in a WinForms application?

前端 未结 3 1192
日久生厌
日久生厌 2020-12-10 12:27

Why does Application.Current come out to null in a WinForms application? How and when is it supposed to be set?

I am doing:

 static clas         


        
3条回答
  •  误落风尘
    2020-12-10 12:55

    Application.Current is Specific for WPF Application. Therefore when you are using WPF controls in WinForms Application you need to initialize instance of WPF Application. Do this in your WinForms Application.

    if ( null == System.Windows.Application.Current )
    {
       new System.Windows.Application();
    } 
    

提交回复
热议问题