RadRibbonView Binding

4 posts, 0 answers
  1. Micko
    Micko avatar
    4 posts
    Member since:
    Feb 2011

    Posted 05 Jul 2012 Link to this post

    Dear all

    Forgive me if this topic has already been discussed albeit I can’t seem to find the relevant thread if it has.

    I have a usercontrol with a radribbonview control and a content control. i.e.


            <telerik:RadRibbonView ApplicationButtonVisibility="Collapsed"




                <telerik:RadRibbonTab Header="Administration" Cursor="Hand">

                    <telerik:RadRibbonGroup Header="User Administration">


    <Usercontrol x:Name=”mainContentWindow” />

    At runtime, a view is injected into the mainContentWindow. What I am trying to achieve is binding a radribbonitem to an element.

    So for example, let’s say I have a button on the ribbon toolbar and I want to bind that button to an element of name diagram (which happens to be a RadDiagram control – separated in another xaml view).

    Any thoughts?



  2. Lancelot
    Lancelot avatar
    251 posts
    Member since:
    Jul 2012

    Posted 06 Jul 2012 Link to this post

    Hi Micko,

    To know about how to use commands and bind them to the content pane, this documentation will bring you to the overview RadRibbonView Overview. What you should to focus on is the button commands, this link will show you how to use the RadRibbonView buttons.

    Here is an example of what the Equation command looks like
    public partial class RibbonButtonsSample : UserControl
       public static readonly RoutedUICommand EquationCommand = new RoutedUICommand(
           typeof( RibbonButtonsSample ) );
       public RibbonButtonsSample()
           CommandManager.AddExecutedHandler( this, this.OnExecuted );
           CommandManager.AddCanExecuteHandler( this, this.OnCanExecute );
       private void OnExecuted( object sender, ExecutedRoutedEventArgs e )
           this.LayoutRoot.Background = new SolidColorBrush( Colors.Blue );
       private void OnCanExecute( object sender, CanExecuteRoutedEventArgs e )
           e.CanExecute = true;

    I hope this helps you resolve your problem getting the buttons to work. Good Luck!


  3. Micko
    Micko avatar
    4 posts
    Member since:
    Feb 2011

    Posted 07 Jul 2012 Link to this post

    Dear Lancelot,

    Thank you for your time in helping me overcome my issue. However, either I do not understand how your recommended approach will help me resolve my problem or I have not explained the problem to you sufficiently.

    Take this scenario - I have a DiagramsControl.xaml with:

    <UserControl...<telerik:RadDiagram x:Name="diagram"
    Grid.Column="1" MinWidth="500" Margin="5,0,0,0"
    BorderThickness="1"Loaded="OnLoaded" SelectionMode="{Binding SelectedItem,
    ElementName=SelectionModeCombo, Mode=TwoWay}">...</UserControl>


    In another xaml (NavigationControl.xaml) I have:

    <telerik:RadRibbonTab Header="Home"
    <telerik:RadRibbonGroup Header="General"
    telerik:ScreenTip.Description="Generic actions."
    Command="telerik:DiagramCommands.Undo" CommandTarget="{Binding
    ElementName=diagram}" LargeImage="Images/Undo.png" Size="Medium"
    <UserControl x:Name=”mainContent”/>

    At runtime DiagramsControl.xaml could be injected in to mainContent. I require my undo button on the ribbon toolbar to bind to the diagram.

    I hope this clarifies the problem.

    Kind regards

  4. Miro Miroslavov
    Miro Miroslavov avatar
    588 posts

    Posted 10 Jul 2012 Link to this post

    Hello michael,

     I don't think is possible to do element name binding to visual that will be dynamically added to the visual tree. This is because of the resolving of the name scopes, when the binding is resolved the "diagram" name is not present in the namescope. In my opinion your best option is to do this by code (set the target explicitly) when your view is injected. Or you may have a property of type RadDiagram in your View (that implements INOtifyPropertychanged or is Dependency Property), which you can bind to the CommandTarget and when your view is injected - just set this property and because it is observable property, the bound target will see the change.
    Please let us know if you have further questions. 

    All the best,
    Miro Miroslavov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top