Use RadWindow as User Control

If you want to prepare the RadWindow at design-time, you have to use it as a user control. To do this you have to create a standard user control using the UserControl template in the Visual Studio. This example will use a UserControl called "RadWindowControl".

After creating it open the XAML file and replace the UserControl declaration with a RadWindow declaration. Here is a sample code:

<telerik:RadWindow x:Class="RadWindowSamples.RadWindowControl" 
Also in the code behind your user control should inherit the RadWindow instead of the UserControl.

public partial class RadWindowControl : RadWindow 
    public RadWindowControl() 
Partial Public Class RadWindowControl 
    Inherits RadWindow 
    Public Sub New() 
    End Sub 
End Class 

If you have installed UI for Silverlight, you can easily create the RadWindow UserControl with the Telerik templates - just click Add -> New Item... in the project Context Menu and choose "Telerik Scenario" from the installed templates. In the Scenario Wizard select RadWindow.

In the XAML you can declare the content of the RadWindow directly in XAML and use the code-behind to wire-up some logic, as you would do with an UserControl. You can also set the properties of the RadWindow. This way you can have a configured RadWindow at design time and the only thing you have to do is to show it, when needed.

As this is an user control of type RadWindow you can use any of the features that are provided by the RadWindow. So if you want to show it, you have to call the Show() method.

RadWindowControl window = new RadWindowControl(); 
Dim window As New RadWindowControl() 

If you're using Implicit Styles to style the controls, note that the newly created user control will not receive automatically the Window style. You should add the following style after the merged dictionaries to fix this:

            <ResourceDictionary Source="Themes/System.Windows.xaml" /> 
            <ResourceDictionary Source="Themes/Telerik.Windows.Controls.xaml" /> 
            <ResourceDictionary Source="Themes/Telerik.Windows.Controls.Navigation.xaml" /> 
        <Style TargetType="local:RadWindowControl" BasedOn="{StaticResource RadWindowStyle}" /> 
The important part is setting TargetType property to the type of the user control.
In this article
Not finding the help you need? Improve this article