Simon
Simon

Reputation: 1312

Telerik RadWindow

I'm facing some issues with Telerik Themes in WPF I have added reference to Telerik.Windows.Themes.Windows8 and merged the resources using the file App.xaml with the following code:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/System.Windows.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Navigation.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/telerik.windows.controls.docking.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

Now I want to apply the Windows 8 Style to my main windows, so I changed it to a telerik:RadWindow

<telerik:RadWindow
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        x:Class="Foo.MainWindow"
        Header="MainWindow" Height="350" Width="525">
    <Grid>
        <TextBlock HorizontalAlignment="Left" Margin="37,79,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/>
        <telerik:RadSlider HorizontalAlignment="Left" Margin="273,156,0,0" VerticalAlignment="Top" Width="200"/>
        <telerik:RadButton Content="Button" HorizontalAlignment="Left" Height="Auto" Margin="158,232,0,0" VerticalAlignment="Top" Width="Auto" Click="ButtonBase_OnClick"/>
    </Grid>
</telerik:RadWindow>

In the designer the theme is applied and anything looks ok: IMG but when I start the application it looks totally different: IMG

I have no idea why this error occurs. If I use the code to create a RadWindow it works perfectly:

RadWindow w = new RadWindow();
w.Width = 500;
w.Height = 500;
w.Show();

Upvotes: 2

Views: 1721

Answers (1)

Charles Mager
Charles Mager

Reputation: 26233

I think as you're using implicit styles you need to state that your window style is based on the implicit styles you've imported. Add this inside your RadWindow XAML:

<telerik:RadWindow.Style>
    <Style TargetType="telerik:RadWindow" BasedOn="{StaticResource RadWindowStyle}" />
</telerik:RadWindow.Style>

Alternatively add this to your resource dictionary (local:MainWindow should resolve to Foo.MainWindow):

<Style BasedOn="{StaticResource RadWindowStyle}" TargetType="local:MainWindow" />

Here are some links that may prove useful:

http://www.telerik.com/forums/show-radwindow-with-implict-style http://www.telerik.com/support/kb/wpf/window/details/how-to-use-radwindow-as-main-window

Upvotes: 3

Related Questions