.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Articles >> Silverlight >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Create Custom Child Window in Silverlight

Posted By:Diptimaya Patra       Posted Date: March 24, 2010    Points: 25    Category: Silverlight    URL: http://www.dotnetspark.com  

Create Custom Child Window in Silverlight. In this article we will see how can we change the Overlay Opacity and Overlay Brush for a Child Window.


Child Window concept is new in Silverlight 3. We will explore some properties that can help us for presentation.

Creating Silverlight 3 Application

Open up Visual Studio 2008 and create a Silverlight 3 Application. Name it as CustomChildWindowInSL3.


Add a Button to the application and name it as btnShow. Follow the xaml code behind:

Now add a Child Window by adding a new Item to the Silverlight Project. Name it as MyChildWindow.


Add a click event to the btnShow Button.


Now navigate to the Event Handler you just added.


Create an object of the ChildWindow and then call the show method of it.

This is normally how we achieve displaying Child Window.

private void btnShow_Click(object sender, RoutedEventArgs e)
   MyChildWindow cw = new MyChildWindow();

Now if you run your application. You can see the Child Window pops up when you click the Button.


In the above figure you can see that, the Overlay Background is Background with some Opacity value.

We can change the above default color scheme.

For Child Window there are two properties called OverlayOpacity and OverlayBrush.

Using the above two properties we will achieve our own Color Scheme.

Go ahead and add the properties and give values. Follow the below code:

private void btnShow_Click(object sender, RoutedEventArgs e)
   MyChildWindow cw = new MyChildWindow();
   cw.OverlayOpacity = 0.5;
   cw.OverlayBrush = new SolidColorBrush(Colors.Red);

In above code, I have assigned the OverlayOpacity to 0.5 and OverlayBrush as Red.

Now we will run our application and see what the changes we have made.


That's it we have successfully customized our Child Window display. You can download the source code for the above example

Enjoy Coding.
 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend