WPF FAQ - Window

Find answers for the most frequently asked questions
Expand All Collapse All

You can load a xaml file dynamically as follows:

[C#]
// This file should then be next to the exe. If not specify a relative path.
FileStream xamlFile = new FileStream('ChartWindow.xaml', FileMode.Open, FileAccess.Read);

Window win = XamlReader.Load(xamlFile) as Window;

win.Show();

Note that any code-behind associated with the above xaml will not be loaded/processed.

In case, you have an assembly reference to a custom dll in the above xaml file, you should reference that assembly with a fully qualified namespace as follows:

[XAML]
xmlns:syncfusion='clr-namespace:Syncfusion.Windows.Chart;assembly=Syncfusion.Chart.WPF,Version=6.303.0.6,Culture=neutral,PublicKeyToken=3d67ed1f87d44c89'

The above assembly should then be present in the GAC for the runtime to find it.

Permalink

No. WPF from version 1 does not include support for MDI. If there is a need for MDI in your application, you can use the windows forms interop or create a custom child window manager.

Permalink

Windows forms can be hosted using the WindowsFormsHost markup extension of the ‘windowsformsintegration.dll’. References for ‘windowsformsintegration.dll’ and ‘System.Windows.Forms.dll’ have to be added.

The following code snippet is used to add a control to the Windows Forms.

Note: windowsformsintegration.dll will be available in the following location,
Program files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsFormsIntegration.dll.

[XAML]

<WindowsFormsHost>
<wf:MaskedTextBox x:Name='mtxamt' Mask='00000.00'/>        </WindowsFormsHost>
Permalink

In WPF, any of the windows can be designated as child windows. A child window is like any other window but it gets minimized or closed when the parent is minimized or closed respectively. This type of window is called modeless dialog. To make a window a child of another window, the ‘Owner’ property of the child window has to be set as the parent window but only after the parent window is shown. Child windows of a window can be enumerated using the ‘OwnedWindows’ read-only property.

Permalink

Share with

Couldn't find the FAQs you're looking for?

Please submit your question and answer.