WPF 응용 프로그램에서 테스트 했을 때에는

아무 문제 없이 잘돌아가던 프로그램이..

UserControl로 변경하여 Winform에서 호스팅하면...

리소스가 없는 문제가 발생한다.

 

Application.Current 개체가 null..........ㅠㅠ

구글링 결과 간단하였다.

 

Application 개체 한번 생성해주고 리소스 불러오면 된다.

 

 

        /// <summary>

        /// Winform에서 호스팅시 Resource Load한다.

        /// </summary>

        private void EnsureApplicationResources()

        {

            if (Application.Current == null)

            {

                new Application();

                ResourceDictionary skinDict = Application.LoadComponent(new Uri(@"/DVCONSOLE;component/Resources\Skins\xxxx.xaml", UriKind.Relative)) as ResourceDictionary;

                Application.Current.Resources = skinDict;

            }

        }

 

 

 

 

 

참조 : Managing Application Resources when WPF is Hosted

+ Recent posts