This is a migrated thread and some comments may be shown as answers.

Unable to display a RadWindow

7 Answers 430 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 1
Pierre asked on 09 Nov 2015, 02:46 PM

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: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

Sort by
0
Accepted
Nasko
Telerik team
answered on 10 Nov 2015, 06:54 AM
Hi Pierre,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Pierre
Top achievements
Rank 1
answered on 10 Nov 2015, 12:39 PM

Yes, that did the trick.  Thanks!

 

0
Gianpaolo
Top achievements
Rank 1
answered on 27 Nov 2015, 01:12 PM
Ihave a modular aplication built with Prism, and the RadWindow i'd like to show is in a module not referenced by the main application, so this solution would not work for me. How can i go about solving this issue?
0
Nasko
Telerik team
answered on 30 Nov 2015, 11:21 AM
Hi Gianpaolo,

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"
        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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Gianpaolo
Top achievements
Rank 1
answered on 30 Nov 2015, 12:02 PM
No unfortunately  it did not work. It is a RadRibbonWindow, not a RadWindow as i stated in my first post. What did work for me is this:

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?

0
Kiril Vandov
Telerik team
answered on 01 Dec 2015, 09:07 AM
Hello Gianpaolo,

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>
dictionary with the style:
RibbonWindowStyle.xaml
 
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Gianpaolo
Top achievements
Rank 1
answered on 09 Dec 2015, 03:51 PM

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.

Tags
General Discussions
Asked by
Pierre
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Pierre
Top achievements
Rank 1
Gianpaolo
Top achievements
Rank 1
Kiril Vandov
Telerik team
Share this question
or