WPF将UserControl添加到RadRibbonTab

时间:2015-10-07 09:28:57

标签: wpf xaml

我正在学习使用WPF。 我正在尝试将RadRibonTab放在一个文件中,而它在另一个文件中是内容,但是我无法做到这一点。

我的父UserControl:

<UserControl x:Class="TelerikTotorial2.RibbonBar.RibonBarView" 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" xmlns:historyTab="clr-namespace:TelerikTotorial2.RibbonBar.History" mc:Ignorable="d" > <telerik:RadRichTextBoxRibbonUI ApplicationButtonContent="File" CollapseThresholdSize="50,50" VerticalAlignment="Top" Margin="0,0,0,-0.2"> <telerik:RadRibbonTab Header="History" HorizontalAlignment="Left" Margin="0" Width="107.2"> <historyTab:HistoryTabView/> </telerik:RadRibbonTab> </telerik:RadRichTextBoxRibbonUI> </UserControl>

我尝试添加的UserControl

<UserControl x:Class="TelerikTotorial2.RibbonBar.History.HistoryTabView"
         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"
         xmlns:history="clr-namespace:TelerikTotorial2.RibbonBar.History"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">

<telerik:RadRibbonGroup Header="Tools">
    <telerik:RadRibbonButton Text="View" Size="Large"/>
</telerik:RadRibbonGroup></UserControl>

但是我得到异常“InvalidOperationException:指定的元素已经是另一个元素的逻辑子元素。” 如果我用

替换<historyTab:HistoryTabView/>

<telerik:RadRibbonGroup Header="Tools"> <telerik:RadRibbonButton Text="View" Size="Large"/> </telerik:RadRibbonGroup>

然后一切正常,但是我希望将这些代码放在单独的文件中。也许有人可以解释我做错了什么?也许不可能将UserControl添加到其他UserControl?

0 个答案:

没有答案