Table of Contents
Using WindowChrome in Code

This section covers the following topic:

Turnning WindowChrome On or Off

By default a WindowChrome is enabled. To disable the WindowChrome, set the WindowChrome's EnableChrome to False:

//Turn off WindowChrome
WindowChrome1.EnableChrome = false;

When a WindowChrome is disabled, it does nothing to change the Window's behavior so the Window would behave as if the WindowChrome control does not exist.

Dynamically Creating a Chromed Window

Use the static CreateChromedWindow method to dynamically create a chromed window in code:

//Dynamically create a chromed window
Window window = WindowChrome.CreateChromedWindow();

//Cast the window's Content into a WindowChrome object
WindowChrome chrome = (WindowChrome)window.Content;

//Set the WindowChrome's Content property. This is
//your window content
chrome.Content = ....

The newly created Window object's Content property is a WindowChrome object. You must cast it to a WindowChrome object, then set the WindowChrome's Content property to add contents to the window.

Chromized an Existing Window

Use the static Chromize method to "chromize" an existing window.

//Chromize an existing window
WindowChrome chrome = WindowChrome.Chromize(window);
Chromize adds a new WindowChrome object into the window if it doesn't already have one; If it already has one, it does nothing and returns the existing WindowChrome object.