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

Usercontrol in a ribbontab

1 Answer 195 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 03 Aug 2011, 03:24 PM
I'm trying to write an app where each part of the config is held in a usercontrol.  In moving this to WPF from winforms I thought it would look good to put the config tabbed in a ribbon at the top.

I tried using the ribbonbar but ran into a problem when a tab was selected that contained a usercontrol  I've now got the RibbonView and tried the same thing and run into the same problem.

My code is:

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:WpfApplication1="clr-namespace:WpfApplication1">
    <Grid>
        <telerik:RadRibbonView Name="radRibbonView1" >
            <telerik:RadRibbonTab>
                <WpfApplication1:UserControl1/
            </telerik:RadRibbonTab>
        </telerik:RadRibbonView>
    </Grid>
</Window>


Where UserControl1 is an empty user control.

When I try to run this, I get the following error:

Specified element is already the logical child of another element. Disconnect it first.

The trace is:

   at System.Windows.FrameworkElement.ChangeLogicalParent(DependencyObject newParent)
   at System.Windows.FrameworkElement.AddLogicalChild(Object child)
   at System.Windows.Controls.HeaderedContentControl.OnHeaderChanged(Object oldHeader, Object newHeader)
   at System.Windows.Controls.HeaderedContentControl.OnHeaderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.StyleHelper.ApplyTemplatedParentValue(DependencyObject container, FrameworkObject child, Int32 childIndex, FrugalStructList`1& childRecordFromChildIndex, DependencyProperty dp, FrameworkElementFactory templateRoot)
   at System.Windows.StyleHelper.InvalidatePropertiesOnTemplateNode(DependencyObject container, FrameworkObject child, Int32 childIndex, FrugalStructList`1& childRecordFromChildIndex, Boolean isDetach, FrameworkElementFactory templateRoot)
   at System.Windows.FrameworkTemplate.InvalidatePropertiesOnTemplate(DependencyObject container, Object currentObject)
   at System.Windows.FrameworkTemplate.HandleBeforeProperties(Object createdObject, DependencyObject& rootObject, DependencyObject container, FrameworkElement feContainer, INameScope nameScope)
   at System.Windows.FrameworkTemplate.<>c__DisplayClass6.<LoadOptimizedTemplateContent>b__3(Object sender, XamlObjectEventArgs args)
   at System.Xaml.XamlObjectWriter.OnBeforeProperties(Object value)
   at System.Xaml.XamlObjectWriter.Logic_CreateAndAssignToParentStart(ObjectWriterContext ctx)
   at System.Xaml.XamlObjectWriter.WriteStartMember(XamlMember property)
   at System.Xaml.XamlWriter.WriteNode(XamlReader reader)
   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter)

1 Answer, 1 is accepted

Sort by
0
Viktor Tsvetkov
Telerik team
answered on 08 Aug 2011, 12:59 PM
Hi Stephen,

You simply need to put first a RadRibbonGroup in the RadRibbonTab and then the usercontrol, because of the hierarchy in the RadRibbonView. If you need further assistance feel free to ask.

Greetings,
Viktor Tsvetkov
the Telerik team

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

Tags
RibbonView and RibbonWindow
Asked by
Stephen
Top achievements
Rank 1
Answers by
Viktor Tsvetkov
Telerik team
Share this question
or