RadControls for Silverlight

This topic will explain you how to work with the RadWindow in details. It will make you familiar with the following:

Create a RadWindow

In order to use the RadWindow in your application you have to add a reference to the Telerik.Windows.Controls.Navigation assembly in your project.

After the reference is available, you can declare a RadWindow. Here is an example.

Note

It's not a good practice do declare your RadWindow as visual element in XAML. The only scenario, when it is meaningful to use the RadWindow in XAML, is when it represents the entire user control. To learn more about that read here.

CopyC#
RadWindow radWindow = new RadWindow();
radWindow.Width = 400;
radWindow.Height = 300;
CopyVB.NET
Dim radWindow As New RadWindow()
radWindow.Width = 400
radWindow.Height = 300

Show the RadWindow

When you want to display the RadWindow you have two options - to display it as a window or as a modal dialog window.

Tip
To learn more about modal windows read here.

Call the Show() method of the RadWindow instance to open it as a normal window.

CopyC#
radWindow.Show();
CopyVB.NET
radWindow.Show()

Call the ShowDialog() method of the RadWindow instance to open it as a modal dialog window.

CopyC#
radWindow.ShowDialog();
CopyVB.NET
radWindow.ShowDialog()

 

Tip
Learn more about positioning the RadWindow by reading the Positioning topic.

Add content to the RadWindow

To add a content to the RadWindow you can use either the Content or the ContentTemplate properties.

If you have a window-specific content, use the Content property.

Tip

As the Content property is of type object you can set it to any control you like. If you want to have a more complex content that consists of more than one control, be sure to wrap them inside a layout control and pass the layout control as content.

You can also set the content of the RadWindow to a UserControl.

Note

The only scenario, where you can add content to the RadWindow at design-time, is when the RadWindow represents an entire user control. To learn more about that read here.

CopyC#
Grid grid = new Grid();
grid.Background = new SolidColorBrush( Color.FromArgb( 255, 240, 255, 255 ) );
radWindow.Content = grid;
CopyVB.NET
Dim grid As New Grid()
grid.Background = New SolidColorBrush(Color.FromArgb(255, 240, 255, 255))
radWindow.Content = grid

If you want to share a common layout structure for the content of multiple windows, define an appropriate DataTemplate and set it to the ContentTemplate property of the RadWindow.

CopyXAML
<UserControl.Resources>
    <DataTemplate x:Key="WindowContentTemplate">
        <Grid Background="Azure" />
    </DataTemplate>
</UserControl.Resources>
CopyC#
radWindow.ContentTemplate = this.Resources[ "WindowContentTemplate" ] as DataTemplate;
CopyVB.NET
radWindow.ContentTemplate = TryCast(Me.Resources("WindowContentTemplate"), DataTemplate)

 

Program the RadWindow

The RadWindow exposes a few methods, that allow you to programmatically control its behavior. Here is a list of them:

  • BringToFront - attempts to bring the RadWidnow over any other RadWindows except topmost.
  • Close - closes the RadWindow.

Modify the appearance of the RadWindow

To modify the default appearance of the RadWindow you can use the following brushes:

  • BorderBrush - changes the outer border of the RadWindow and the outer border of its content area.
  • Background - changes the background of the content area.
  • ModalBackground - changes the color of the background behind the RadWindow when it is opened as a modal dialog.

Also you can create a style and apply it to the RadWindow or modify the default template of the RadWindow to change its overall look. To learn more read the Styles and Templates section.

See Also