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

Nested RadRibbonDropDownButtons - odd behavior.

1 Answer 43 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
scott
Top achievements
Rank 1
scott asked on 21 Nov 2012, 07:12 PM
I have a ribbon looking like this:
<UserControl x:Class="q_telerik2.MainPage"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot">
<telerik:RadRibbonView>
<telerik:RadRibbonTab>
<telerik:RadRibbonGroup>
<telerik:RadRibbonDropDownButton Name="ribbonButton" DropDownOpening="RadRibbonDropDownButton_DropDownOpening" Content="Click Me">
</telerik:RadRibbonDropDownButton>
</telerik:RadRibbonGroup>
</telerik:RadRibbonTab>
</telerik:RadRibbonView>
</Grid>
</UserControl>




And I populate it like this:

private void RadRibbonDropDownButton_DropDownOpening(object sender, RoutedEventArgs e)
{
    StackPanel sp = new StackPanel();
    for (int i = 1; i < 5; i++)
    {
        RadDropDownButton childButton = new RadDropDownButton() { Content = "Choice " + i.ToString() };
        sp.Children.Add(childButton);
 
        StackPanel childContent = new StackPanel();
        for (int j=1 ; j<5; j++)
        {
            TextBlock tb = new TextBlock() { Text = j.ToString() + ".  Why do we display up here?" };
            childContent.Children.Add(tb);
        }
        childButton.DropDownContent = childContent;
    }
    ribbonButton.DropDownContent = sp;
}


The TextBlock content doesn't display near its parent drop down button, but at {0,0} of the window...

I've attached a pic of what I see.  Is this something I'm doing wrong or is there a workaround?

Thanks -







1 Answer, 1 is accepted

Sort by
0
Kiril Vandov
Telerik team
answered on 23 Nov 2012, 12:06 PM
Hi Scott,

When we use RoutedEvents and both the parent and the children share same events, we have to assure that the sender and the original source are equal otherwise the event will be called again when we try to open the nested buttons. I added the needed verification, here is a code snippet  for it:

private void RadRibbonDropDownButton_DropDownOpening(object sender, RoutedEventArgs e)
{
    var button = (e as RadRoutedEventArgs).OriginalSource as RadDropDownButton;
    if (button == sender)
    {
        StackPanel sp = new StackPanel();
        for (int i = 1; i < 5; i++)
        {
            RadDropDownButton childButton = new RadDropDownButton() { Content = "Choice " + i.ToString() };
 
            StackPanel childContent = new StackPanel();
            for (int j = 1; j < 5; j++)
            {
                TextBlock tb = new TextBlock() { Text = j.ToString() + ".  Why do we display up here?" };
                childContent.Children.Add(tb);
            }
            childButton.DropDownContent = childContent;
            sp.Children.Add(childButton);
        }
        button.DropDownContent = sp;
    }
}
Hope this helps. Please let us know if you need more info.

Regards,
Kiril Vandov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RibbonView and RibbonWindow
Asked by
scott
Top achievements
Rank 1
Answers by
Kiril Vandov
Telerik team
Share this question
or