I've been going at this for 2 hours. I don't understand why it's so hard to display a simple RadWindow.
PreferencesView.xaml
<
telerik:RadWindow
x:Class
=
"MainWindow.Preferences.PreferencesView"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:local
=
"clr-namespace:MainWindow.Preferences"
mc:Ignorable
=
"d"
Height
=
"350"
Width
=
"300"
>
<
DockPanel
Margin
=
"10"
>
<
StackPanel
DockPanel.Dock
=
"Bottom"
Orientation
=
"Horizontal"
VerticalAlignment
=
"Bottom"
HorizontalAlignment
=
"Right"
>
<
telerik:RadButton
Content
=
"OK"
/>
<
telerik:RadButton
Content
=
"Cancel"
Margin
=
"5,0,0,0"
/>
</
StackPanel
>
</
DockPanel
>
</
telerik:RadWindow
>
Caller
PreferencesView preferencesView = new PreferencesView();
preferencesView.ResizeMode = ResizeMode.NoResize;
preferencesView.WindowStartupLocation = WindowStartupLocation.CenterOwner;
preferencesView.Owner = this;
preferencesView.ShowDialog();
The RadWindow seems to exist because I can show its system menu with Alt-Space. For some reason, I only see a think frame of the RadWindow and its entire content is blank. I do use a global theme that I've set in App.xaml and my MainWindow uses it fine.
What am I doing wrong?
7 Answers, 1 is accepted
If you are using Implicit Styles in order to apply the desired theme, please notice that the newly created user control (PreferencesView in your case) will not receive the default Style of RadWindow.
So, in order to fix that you need to add the following Style after the merged dictionaries:
<
Application.Resources
>
<
ResourceDictionary
>
<
ResourceDictionary.MergedDictionaries
>
<
ResourceDictionary
Source
=
"Themes/System.Windows.xaml"
/>
<
ResourceDictionary
Source
=
"Themes/Telerik.Windows.Controls.xaml"
/>
<
ResourceDictionary
Source
=
"Themes/Telerik.Windows.Controls.Navigation.xaml"
/>
</
ResourceDictionary.MergedDictionaries
>
<-- the TargetType should be your UserControl (MainWindow) that contains and inherits RadWindow -->
<
Style
TargetType
=
"local:PreferencesView"
BasedOn
=
"{StaticResource RadWindowStyle}"
/>
</
ResourceDictionary
>
</
Application.Resources
>
More detailed information you could find in the following article from our help documentation:
http://docs.telerik.com/devtools/wpf/controls/radwindow/how-to/use-radwindow-as-user-control
Could you please give a try to the proposed above approach and let us know if it worked for you?
Hope this helps.
Regards,
Nasko
Telerik
Yes, that did the trick. Thanks!
From the provided description of your scenario it seems that you do not have App.xaml. If that is the case what we could suggest is to load the Style dynamically to RadWindow as shown below:
<
telerik:RadWindow
x:Class
=
"RadWindowAsMainWindow.MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
Style
=
"{DynamicResource RadWindowStyle}"
Header
=
"MainWindow"
Height
=
"350"
Width
=
"525"
>
...
</
telerik:RadWindow
>
Please, give it a try and let us know if that worked for you or we should thing of another approach.
Hope this helps.
Regards,
Nasko
Telerik
static PivotGridWindow()
{
RadRibbonWindow.IsWindowsThemeEnabled = false;
}
public PivotGridWindow()
{
InitializeComponent();
Loaded += PivotGridWindow_Loaded;
}
void PivotGridWindow_Loaded(object sender, RoutedEventArgs e)
{
(sender as RadRibbonWindow).Style = Application.Current.Resources["RadRibbonWindowStyle"] as Style;
}
but i would not want to repeat this for every new window i need to add. Is there a more elegant solution?
If I understand your correctly you are having a Prism solution and the RadRibbonWindow module is defined in a separate ClassLibrary which does not have reference to the main application (this is the correct way set up a Prism solution). And you are opening a new RadRibbonWindow instances which refer to same module (RibbonWIndowModule) on a button click from your main application. If that is the case you could follow this article and see how to define implicit style which will be applied to the window of a given type.
App.xaml
<
Application.Resources
>
<
ResourceDictionary
>
<
ResourceDictionary.MergedDictionaries
>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows7;component/Themes/System.Windows.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.Input.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.Navigation.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.RibbonView.xaml"
/>
<
ResourceDictionary
Source
=
"RibbonWindowStyle.xaml"
/>
</
ResourceDictionary.MergedDictionaries
>
</
ResourceDictionary
>
</
Application.Resources
>
RibbonWindowStyle.xaml
<
ResourceDictionary
xmlns
=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:local
=
"clr-namespace:RibbonWindow_ImplicitStylesDemo"
>
<
Style
TargetType
=
"local:MainWindow"
BasedOn
=
"{StaticResource RadRibbonWindowStyle}"
/>
</
ResourceDictionary
>
If that does not solve your problem, could you please attach us a sample project demonstrating how you are using the RadRibbonWindow. Doing so we will better understand your scenario and we could provide you with the best possible solution for your case.
Looking forward to hearing from you.
Kind regards,
Kiril Vandov
Telerik
Hello Kiril, thanks for your answer. Preparing a sample project to show the problem helped me understand the problem in my main application. I can confirm that the first solution of using DynamicResource does work, and that the RadRibbonWindowStyle was being overwritten elsewhere in my application.
Thank you.