RadRibbonWindow inside User control

7 posts, 0 answers
  1. Madhu
    Madhu avatar
    4 posts
    Member since:
    Sep 2013

    Posted 09 Sep 2013 Link to this post

    Hi,

    I am trying to use RadRibbonView inside my user control.
    And since RadRibbonView does not work unless we include RadRibbonWindow, I have tried to add it to my User control.

    It is always giving exception.
    "Set property 'System.Windows.Controls.ContentControl.Content' threw an exception.' Line number '6' and line position '14'."

    Here is my Code:(XAML:)

    <UserControl x:Class="TestTelerikRibbonApp.UserControlTab1"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                 Name="UCTestTab1"
                 mc:Ignorable="d" 
                 d:DesignHeight="330" d:DesignWidth="488">    
        
        <telerik:RadRibbonWindow>
            <telerik:RadRibbonView x:Name="rbvTest">
                <telerik:RadRibbonTab Header="RadRibbon" HorizontalAlignment="Left" Margin="0,0,0,0" Name="radRibbonTab" VerticalAlignment="Top">               
                    <telerik:RadRibbonGroup Header="Home" Name="rgHome">
                    </telerik:RadRibbonGroup>
                </telerik:RadRibbonTab>
            </telerik:RadRibbonView>
        </telerik:RadRibbonWindow>
    </UserControl>

  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 09 Sep 2013 Link to this post

    Hello,

    The exception that you get is caused by the fact that the RadRibbonWindow derives from the native Window class. However a Window must be the root of the tree and it cannot be added as a child of Visual.

    So if you want to use a RibbonWindow you need to make sure to define it as a root of a tree as you would use a native Window object:
    <telerik:RadRibbonWindow x:Class="WpfApplication2.MyRibbonWindow"
                 ...>
            <telerik:RadRibbonView x:Name="rbvTest">
                <telerik:RadRibbonTab Header="RadRibbon"
                                      HorizontalAlignment="Left"
                                      Margin="0,0,0,0"
                                      Name="radRibbonTab"
                                      VerticalAlignment="Top">
                    <telerik:RadRibbonGroup Header="Home"
                                  Name="rgHome">            
                           </
    telerik:RadRibbonGroup>
                </telerik:RadRibbonTab>
            </telerik:RadRibbonView>
    </telerik:RadRibbonWindow>

    Also please have in mind that the main purpose of the RibbonWindow is to provide you with a more fluent UI when hosting the RibbonView in a window as the RibbonView title, layout and style is synchronized with the RibbonWindow. But that does not necessarily mean that you need to use the RibbonView in a RibbonWindow.

    And if you have encountered any issues using the RibbonView outside a RibbonWindow, please let us know so that we can address them accordingly.

    Regards,
    Tina Stancheva
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Madhu
    Madhu avatar
    4 posts
    Member since:
    Sep 2013

    Posted 10 Sep 2013 Link to this post

    Hi Tina,

    I understand that RibbonWindow need to be defined as a root of a tree as you would use a native Window object.

    But my problem is i dont want to change my Main window to telerik:RadRibbonWindow

    I am having Mainwindow which has number of User Controls which will be used apart from the usercontrol(TestTelerikRibbonApp.UserControlTab1which i am creating.

    So, i cant change my Main window to RadRibbonWindow because there are other user controls(which are not using telerik controls)
    accessing that main window.

    So i wanted to create a User Control which contains a RadRibbonView.
    But when i am trying to use just RadRibbonView, i am getting exception.

    <UserContol x:Class="TestTelerikRibbonApp.UserControlTab1
    "
                 ...>
            <telerik:RadRibbonView x:Name="rbvTest">
                <telerik:RadRibbonTab Header="RadRibbon"
                                      HorizontalAlignment="Left"
                                      Margin="0,0,0,0"
                                      Name="radRibbonTab"
                                      VerticalAlignment="Top">
                    <telerik:RadRibbonGroup Header="Home"
                                  Name="rgHome">             
                           </
    telerik:RadRibbonGroup>
                </telerik:RadRibbonTab>
            </telerik:RadRibbonView>
    </UserControl>



    So i tried to wrap RadRibbonView within RadRibbonWindow.
    Please let me know how to proceed.

    Thanks,
    Madhu

  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 10 Sep 2013 Link to this post

    Hello Madhu,

    I was not able to detect any issues with the approach you essentially need to implement. I can successfully add a RibbonView in a UserControl and then add it in the MainWindow of the application. Please have a look at the attached sample and let me know if there is something I am missing.

    Regards,
    Tina Stancheva
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  6. Madhu
    Madhu avatar
    4 posts
    Member since:
    Sep 2013

    Posted 11 Sep 2013 Link to this post

    Anyone, please help me.
  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 11 Sep 2013 Link to this post

    Hello Madhu,

    Can you please elaborate a bit more on the issue you're experiencing? In my previous post I attached a sample project to demonstrate how to put the RadRibbonView in an UserControl and then place it in a Window. Can you please have a look at the solution and let me know if it works for you?

    Also, if you feel that there is something I'm missing, please modify the solution accordingly. This would help me better understand the issue you're experiencing and advice you how to get over it.

    Regards,
    Tina Stancheva
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  8. Madhu
    Madhu avatar
    4 posts
    Member since:
    Sep 2013

    Posted 12 Sep 2013 Link to this post

    Hi Tina,

    Earlier, i did get an error forcing me to include RadRibbonWindow to wrap around RadRibbonView.
    But it is working fine right now without any modifications. I am not able to reproduce the error.

    Anyways,Thanks for your Help.

    Regards,
    Madhu
Back to Top
UI for WPF is Visual Studio 2017 Ready