A-Max Lee
A-Max Lee

Reputation: 27

Debug a WPF window or Windows Form without running your application?

I'm new to WPF and have a question which quite same with the article: "Walkthrough: Debug a WPF window or Windows Form without running your application".

The link: http://blogs.msdn.com/b/habibh/archive/2009/07/17/walkthrough-debug-a-wpf-window-or-windows-form-without-running-your-application-video.aspx

I will take the picture as an example: http://blogs.msdn.com/blogfiles/habibh/WindowsLiveWriter/DebugaWPFwindoworWindowsFormwithoutrunni_FD38/image_3.png

From the picture, the project have 4 WPF windows such as:

  1. App.xaml
  2. Create...so on.xaml
  3. MainWindows.xaml
  4. ViewChart... so on.xaml

When every time in VS 2010, I click on the starting debugging (F5) or start without debugging(Ctrl + F5) will always run the MainWindows.xaml. What the reason coz this? Is this because of in the App.xaml that we declare StartupUri="MainWindow.xaml".

Can I run the particular WPF windows such number 4. ViewChart... so on.xaml instead of the whole application(*Such as the MainWindows.xaml)?

Upvotes: 1

Views: 3667

Answers (1)

Claies
Claies

Reputation: 22323

The article you linked is out of date and the video that demonstrates his solution is no longer hosted. However, the basic steps that were outlined in the video are still possible, though the process can be more trouble than it's worth.

The process is as follows:

  1. Open the Immediate Debugger window (Debug -> Windows -> Immediate Window)
  2. In the Immediate mode, create an instance of the window you are wishing to test.
  3. call the ShowDialog() method on your Immediate instance.

The main trouble with this method of debugging is that if your window has a complex constructor or has dependencies on external objects, you may end up spending more time setting up the dependencies than just navigating to the page would have taken.

Upvotes: 6

Related Questions