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.MainWindow" 
Also in the code behind your user control should inherit the RadWindow instead of the UserControl.

public partial class MainWindow : RadWindow 
    public MainWindow() 
Partial Public Class MainWindow 
    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.

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

If you want to use RadWindow as the main window of the application, remove the StartupUri setting in the App.xaml file. Then create a new instance of the custom RadWindow and show it in the OnStartup method override of the App class.

public partial class App : Application 
    protected override void OnStartup(StartupEventArgs e) 
        MainWindow window = new MainWindow(); 
Public Partial Class App 
    Inherits Application 
    Protected Overrides Sub OnStartup(ByVal e As StartupEventArgs) 
    Dim window As MainWindow = New MainWindow() 
    End Sub 
End Class 

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