![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | Reference a xaml window from a WinFX Custom Control Library ? Hello all, I wish to contain all the xaml/code for my project within a custom control library (DLL). The exe project will contain only a MyApp.xaml that runs the first window of the application from teh DLL. How can I accomplish this? Also, the eventual intention of this is testing via NUnit w/ System.Windows.Automation from another DLL that is the NUnit target library (Test Runner). What is required in this scenario to setup the test target (xaml window) for automation control and inspection? Thank you all for your advice and support! |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Reference a xaml window from a WinFX Custom Control Library ? > Hello all, > > I wish to contain all the xaml/code for my project within a custom > control library (DLL). The exe project will contain only a MyApp.xaml > that runs the first window of the application from teh DLL. > > How can I accomplish this? You need to just control the application initialization yourself. 1. Don't set StartupUri. 2. Override Application::OnStartup[1] 3. Instantiate the Window class from the control library and pass it to Application::Run[2]. > Also, the eventual intention of this is testing via NUnit w/ > System.Windows.Automation from another DLL that is the NUnit target > library (Test Runner). What is required in this scenario to setup the > test target (xaml window) for automation control and inspection? I don't have an answer to this one since I haven't done enough with automation yet. Basically though you'll need to make sure there's a Dispatcher running for the thread (implies STA) that NUnit has created. Once there's a Dispatcher I think you should just be able to create a window instance and go to town. HTH, Drew [1] http://windowssdk.msdn.microsoft.com...asp?frame=true [2] http://windowssdk.msdn.microsoft.com...1_ac53f552.asp ___________________________________ Drew Marsh Chief Software Architect Mimeo.com, Inc. - http://www.mimeo.com Microsoft C# / WPF MVP Weblog - http://blog.hackedbrain.com/ |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Reference a xaml window from a WinFX Custom Control Library ? I wrote: > 3. Instantiate the Window class from the control library and pass it > to Application::Run[2]. Sorry, just thought about this some more and realized it's bad advice because the application's already had its Run called by the Main method that's provided by the MyApp.g.cs. Do this as the third step instead: protected override OnStartup(StartingUpEventArgs args) { Window mainWindow = new YourWindowFromTheLibrary(); this.MainWindow = mainWindow; mainWindow.Show(); base.OnStartup(e); } HTH, Drew |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Reference a xaml window from a WinFX Custom Control Library ? HI Drew, I got this working... that is, unit-test XAML windows with NUnit. The result is an adventure into System.Threading and a firm grasp on the requirements of Nunit (runs everything on an MTA thread) and WPF (Window runs on STA thread). Here's my post : http://fitzgibbons.info/articles/200...dow-with-nunit "Drew Marsh" wrote: > > Hello all, > > > > I wish to contain all the xaml/code for my project within a custom > > control library (DLL). The exe project will contain only a MyApp.xaml > > that runs the first window of the application from teh DLL. > > > > How can I accomplish this? > > You need to just control the application initialization yourself. > > 1. Don't set StartupUri. > 2. Override Application::OnStartup[1] > 3. Instantiate the Window class from the control library and pass it to Application::Run[2]. > > > Also, the eventual intention of this is testing via NUnit w/ > > System.Windows.Automation from another DLL that is the NUnit target > > library (Test Runner). What is required in this scenario to setup the > > test target (xaml window) for automation control and inspection? > > I don't have an answer to this one since I haven't done enough with automation > yet. Basically though you'll need to make sure there's a Dispatcher running > for the thread (implies STA) that NUnit has created. Once there's a Dispatcher > I think you should just be able to create a window instance and go to town. > > HTH, > Drew > > [1] http://windowssdk.msdn.microsoft.com...asp?frame=true > [2] http://windowssdk.msdn.microsoft.com...1_ac53f552.asp > ___________________________________ > Drew Marsh > Chief Software Architect > Mimeo.com, Inc. - http://www.mimeo.com > Microsoft C# / WPF MVP > Weblog - http://blog.hackedbrain.com/ > > > |
My System Specs![]() |
| Thread Tools | |
| |