Unable to display a RadWindow

8 posts, 1 answers
  1. Pierre
    Pierre avatar
    23 posts
    Member since:
    Oct 2015

    Posted 09 Nov 2015 Link to this post

    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?

  2. Answer
    Nasko
    Admin
    Nasko avatar
    587 posts

    Posted 10 Nov 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Pierre
    Pierre avatar
    23 posts
    Member since:
    Oct 2015

    Posted 10 Nov 2015 Link to this post

    Yes, that did the trick.  Thanks!

     

  5. Gianpaolo
    Gianpaolo avatar
    9 posts
    Member since:
    Nov 2013

    Posted 27 Nov 2015 Link to this post

    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?
  6. Nasko
    Admin
    Nasko avatar
    587 posts

    Posted 30 Nov 2015 Link to this post

    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
  7. Gianpaolo
    Gianpaolo avatar
    9 posts
    Member since:
    Nov 2013

    Posted 30 Nov 2015 in reply to Nasko Link to this post

    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?

  8. Kiril Vandov
    Admin
    Kiril Vandov avatar
    324 posts

    Posted 01 Dec 2015 Link to this post

    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
  9. Gianpaolo
    Gianpaolo avatar
    9 posts
    Member since:
    Nov 2013

    Posted 09 Dec 2015 Link to this post

    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.

Back to Top
UI for WPF is Visual Studio 2017 Ready