Click here to Skip to main content
13,590,564 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 20 Oct 2010
Licenced CPOL

Simplest Way to Create a Non-Movable Silverlight Child Window

, 20 Oct 2010
Rate this:
Please Sign up or sign in to vote.
Simplest Way to Create a Non-Movable Silverlight Child Window

Are you looking for a Silverlight Child Window which can't move from its actual position? Then this article will help you to understand and create a non-movable child window in Silverlight.

Child Window is available inside the System.Windows.Controls.dll assembly. By default, it is movable. You can drag the Title Bar of the Window and position it anywhere in the screen. But, you may face some situation when you need to fix the position of the Window by restricting the user to drag it. So, how will you do this?

In this article, I will show you the simplest mechanism to make your child window not movable.

Creating the Basic UI with ChildWindow

Open your Expression Blend and create a Silverlight project. I am not demonstrating how to create a project now, as I think you are familiar with that. If you are not familiar with that, read any of my earlier articles to know about it.

Once your Silverlight project is with you, go to the “Assets” tab as shown below and start searching for the “ChildWindow”. Add the Child Window to your Grid Layout. Now resize it properly and set a comfortable position of it as per your choice.


If you run your application now, you will see the child window present in the UI. Click on the title bar position and try to drag it in any location. You will see that it changes its position.

Create a Template for the ChildWindow

Once you add the ChildWindow into the screen, we have to change the style by editing the template of the control. To do this, inside the blend IDE, right click on the child window control. From the context menu, select “Edit Template” –> “Edit a Copy…”.


Now it will popup the “Create Style Resource” dialog to the screen. Give a proper name for your style, e.g., “NonMovableChildWindowStyle”. Click “ok” to continue. If you want to set this style for all of your ChildWindows automatically, don't give any name here. Instead, select “Apply to all”. This will apply it globally.


Modifying the Style

Now you need to modify the generated style. Once you click on “Edit Copy…”, this will open the template editor in the same screen. Expand all the panels to reach to the border panel named “Chrome”. Here is the screen shot of the same:


In the XAML, you will see the below code:


Search for the word “Chrome” if you are facing any difficulty as it generates a huge XAML code. Once you find out the code, just remove the x:Name=”Chrome” from the Border control.


Once you remove the x:Name=”Chrome” from the border control, the code will look similar to this:


Now run your application once again and try to drag the ChildWindow. You will notice that the child window is not movable now.

As an alternative to the above find and delete method, you can also remove the name easily from the blend IDE. In the template explorer, click on the Border control named “Chrome” and you will notice it selected as below:


Now delete the name from the control. That’s it. It will remove the x:Name from the XAML and look like the below screenshot:


In this case also, if you run your application, your child window will not get the event for moving around the screen.

End Note

As we removed the name “Chrome” from the XAML code, the ChildWindow implementation will not find the declaration of the “Chrome” and hence it will not do the dragging functionality.

This is just a simple hack I did for the ChildWindow today and wanted to share the same trick with you. To do it properly, you can create your own ChildWindow class extended from the base ChildWindow. Then create some properties to set whether it will be movable or not and based on the bool value, set the dragging functionality to the Child Window.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Kunal Chowdhury «IN»
Software Developer (Senior)
India India
Kunal Chowdhury is a Microsoft "Windows Platform Development" MVP (Most Valuable Professional), a Codeproject Mentor, Telerik Developer Expert, Nokia Developer Champion, Windows 10 Champion, Microsoft Rockstar, Speaker in various Microsoft events, Author, passionate Blogger and a Software Engineer by profession.

He is currently working in an MNC located in India. He has a very good skill over XAML, C#, Silverlight, Windows Phone, WPF and Windows Store (WinRT) app development. He posts his findings, articles, tutorials in his technical blog and CodeProject.

Book authored:

Connect with me on:

My CodeProject Awards/Prizes:

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
Hiren Solanki20-Oct-10 20:10
memberHiren Solanki20-Oct-10 20:10 
GeneralRe: My vote of 5 Pin
KunalChowdhury20-Oct-10 22:33
mentorKunalChowdhury20-Oct-10 22:33 
GeneralMy vote of 5 Pin
Abhijit Jana20-Oct-10 16:07
mvpAbhijit Jana20-Oct-10 16:07 
GeneralRe: My vote of 5 Pin
KunalChowdhury20-Oct-10 18:19
mentorKunalChowdhury20-Oct-10 18:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03-2016 | 2.8.180618.1 | Last Updated 20 Oct 2010
Article Copyright 2010 by Kunal Chowdhury «IN»
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid