Customizing Child Window In Silverlight 3

No.of Views2106
Bookmarked0 times
Downloads 
Votes0
By  dpatra   On  16 Feb 2010 00:02:01
Tag : Silver Light and XAML , How to
Customizing Child Window In Silverlight 3
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 Introduction
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.

Image Loading....


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

{codecitation class="brush: html; gutter: true;" width="650px"}

<Button x:Name="btnShow" VerticalAlignment="Top" Content="Show ChildWindow" Margin="0,98,0,0" HorizontalAlignment="Center" Width="130"/>

{/codecitation}

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

Image Loading....



Add a click event to the btnShow Button.

Image Loading...

Now navigate to the Event Handler you just added.

Image Loading...

Create an object of the ChildWindow and then call the show method of it.
This is normally how we achieve displaying Child Window.

{codecitation class="brush: csharp; gutter: true;" width="650px"}

private void btnShow_Click(object sender, RoutedEventArgs e)
{
MyChildWindow cw = new MyChildWindow();
cw.Show();
}
{/codecitation}


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

Image Loading...

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:

{codecitation class="brush: csharp; gutter: true;" width="650px"}

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

{/codecitation}

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.

Image Loading....

That’s it we have successfully customized our Child Window display.Enjoy Coding.

Thank you


About the Author


Diptimaya Patra

Description :I am a Master in Computer Application (MCA) from SRM University, Chennai. I am MCTS in ASP.Net Web Development, and MOSS 2007 Administration. I have extreme exposure to Microsoft Technologies in recent times like Silverlight 2, Silverlight 3. I am from Cuttack, Orissa. You can reach me using this mail (diptimaya.patra@gmail.com). Currently I am working as a Software Engineer in UST Global Inc in Trivandrum Center.

Occupation :Software Engineer
Company : UST Global.
Location : India
Follow me at twitter : http://twitter.com/dpatra


 
Sign Up to vote for this article
 
About Author
 
dpatra
Occupation-Not Provided
Company-Not Provided
Member Type-Expert
Location-Not Provided
Joined date-13 Jul 2009
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top