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

RadRibbonView Binding

3 Answers 131 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
Micko
Top achievements
Rank 1
Micko asked on 05 Jul 2012, 04:09 PM

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.

<StackPanel>

        <telerik:RadRibbonView ApplicationButtonVisibility="Collapsed"

                                                                      TitleBarVisibility="Collapsed"

                                                                      MinimizeButtonVisibility="Visible"

                                                                      Background="{x:Null}">

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

Cheers

Micko

3 Answers, 1 is accepted

Sort by
0
Lancelot
Top achievements
Rank 1
answered on 06 Jul 2012, 08:51 PM
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(
       "Equation",
       "EquationCommand",
       typeof( RibbonButtonsSample ) );
   public RibbonButtonsSample()
   {
       InitializeComponent();
       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!

Lancelot




0
Micko
Top achievements
Rank 1
answered on 07 Jul 2012, 10:39 AM

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:

<UserControl>
...
<telerik:RadRibbonView
ApplicationButtonVisibility="Collapsed"
TitleBarVisibility="Collapsed"
MinimizeButtonVisibility="Visible"
Background="{x:Null}">
<telerik:RadRibbonTab Header="Home"
IsSelected="true"
telerik:KeyTipService.AccessText="1";
<telerik:RadRibbonGroup Header="General"
telerik:ScreenTip.Description="Generic actions."
telerik:ScreenTip.Title="General">
<telerik:RadRibbonSplitButton
Command="telerik:DiagramCommands.Undo" CommandTarget="{Binding
ElementName=diagram}" LargeImage="Images/Undo.png" Size="Medium"
...
<UserControl x:Name=”mainContent”/>
...
</UserControl>

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
Michael

0
Miro Miroslavov
Telerik team
answered on 10 Jul 2012, 07:54 AM
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 >>

Tags
RibbonView and RibbonWindow
Asked by
Micko
Top achievements
Rank 1
Answers by
Lancelot
Top achievements
Rank 1
Micko
Top achievements
Rank 1
Miro Miroslavov
Telerik team
Share this question
or