You can open the MDriven runtime WPF debugger from your own WPF application to inspect and debug expressions against the application's current EcoSpace; this page is for developers embedding that debugger in a WPF application.
What the runtime WPF debugger does
The runtime debugger is MDriven.WPF.Debugger.OCLRuntimeDebuggerWPF. Create it with the application's current EcoSpace and show it as a WPF window.
Use this debugger when you need to investigate runtime expression behavior in an application that uses MDriven WPF UI. For debugging from within MDriven Designer, use OCL Debugger instead. For inspecting or changing the MDriven model itself, see Documentation:Using the model debugger to change the model itself.
Add the debugger to a WPF application
Create and show the debugger at the point where your application has a current EcoSpace.
- Ensure that the WPF dequeuer is active.
- Create
OCLRuntimeDebuggerWPFwithGA.Singleton.GetCurrentEcoSpace(). - Call
Show()to open the debugger window.
Eco.WPF.WPFDequeuer.Active = true;
var wpfdebugger = new MDriven.WPF.Debugger.OCLRuntimeDebuggerWPF(
GA.Singleton.GetCurrentEcoSpace());
wpfdebugger.Show();
Eco.WPF.WPFDequeuer.Active = true is required by the debugger. It is also required for MDriven WPF UI so that derivations displayed on screen are evaluated.
The debugger receives the current EcoSpace through GA.Singleton.GetCurrentEcoSpace(). In practice, this means that you should open it only after the application has established the EcoSpace you intend to inspect.
Support a WinForms application that hosts WPF windows
If your application object is a WinForms application and the application uses WPF windows, enable modeless keyboard interoperability for each WPF window. Without this setup, keyboard input and events may not work correctly in the true WPF forms running in the WinForms environment.
Add the following code in addition to the basic debugger setup:
Eco.WPF.WPFDequeuer.Active = true;
var wpfdebugger = new MDriven.WPF.Debugger.OCLRuntimeDebuggerWPF(
GA.Singleton.GetCurrentEcoSpace());
// Required when the WinForms application hosts WPF forms.
AutoFormWPF.OnNewAutoFormWPFCreated += (s, e) =>
{
System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(
e.AutoFormWPF);
};
System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(
wpfdebugger);
wpfdebugger.Show();
The event handler applies EnableModelessKeyboardInterop to every new AutoFormWPF. The second call applies the same setting to the debugger window itself.
| Application setup | Required setup |
|---|---|
| WPF application using the runtime debugger | Set Eco.WPF.WPFDequeuer.Active = true, create OCLRuntimeDebuggerWPF with the current EcoSpace, then call Show().
|
| WinForms application that uses WPF forms, including the runtime debugger | Use the WPF setup and call ElementHost.EnableModelessKeyboardInterop for each new AutoFormWPF and for the debugger window.
|
Example: open the debugger from application code
The following example opens a debugger against the current EcoSpace. In a mixed WinForms/WPF application, retain the interoperability lines shown in the previous section.
private void OpenRuntimeDebugger()
{
Eco.WPF.WPFDequeuer.Active = true;
var debugger = new MDriven.WPF.Debugger.OCLRuntimeDebuggerWPF(
GA.Singleton.GetCurrentEcoSpace());
debugger.Show();
}
This page covers opening the WPF debugger in a running application. It does not describe the Designer debugging workflow or model maintenance workflow:
- Use OCL Debugger to start and use the debugger from MDriven Designer.
- Use the model debugger when you need to inspect or alter model elements, such as classes, tagged values, and actions.
- If a model check reports an error that is difficult to locate, see Documentation:Check model error.
For context on the WPF runtime client and its ViewModel-based information tree, see Documentation:Windows WPF client. For prototyping-engine background, see Documentation:WECPOF.
