2016-03-20 55 views
0

我有一个WPF功能区的应用程序和一个DLL。WPF:以编程方式将RibbonBar从UserControl添加到RibbonWindow RibbonTab

在应用程序中,我使用第三方来源(Syncfusion)创建RibbonWindow。

该DLL是一个WPF类库,它由一个RibbonBar的UserControl组成。

我想将UserControl添加到我的RibbonWindow中。

我不知道如何以编程方式做到这一点。

MainWindow.xaml.cs

动态加载来自DLL

 Assembly asm = Assembly.LoadFile(unitDllPath); 
     Type typ = asm.GetType("WX" + ".UserControl1", true, true); 
     unitDll = Activator.CreateInstance(typ); 

MainWindow.xaml

<syncfusion:RibbonTab Name="Tab1" IsChecked="True" > 

    </syncfusion:RibbonTab> 

UserControl.xaml

<syncfusion:RibbonBar Header="Select" Name="Bar1" ></syncfusion:RibbonBar> 

UserControl.xam用户控件l.cs

 public void MainWindow() 
    { 
     InitializeComponent(); 
    } 

如何从WX.UserControl(Bar1)将RibbonBar转换为(Tab1)?

感谢。

回答

0

1)如果我们需要以编程方式添加用户控件这是一个RibbonBar您RibbonWindow,你的用户控件应该像下面

UserControl.xaml

<syncfusion:RibbonBar x:Class="WPFClassLibrary.UserControl1" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:syncfusion="http://schemas.syncfusion.com/wpf" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     mc:Ignorable="d" 
     d:DesignHeight="300" d:DesignWidth="300"> 
     <syncfusion:RibbonButton SizeForm="Large" Label="New Email"/> 
     <syncfusion:RibbonButton SizeForm="Large" Label="Inbox"/> 
     <syncfusion:RibbonButton SizeForm="Large" Label="Drafts"/> 
     <syncfusion:RibbonButton SizeForm="Large" Label="OutBox"/> 

2)参照大会文件在您的应用程序。

3)使用大会后面的代码像下面

using WPFClassLibrary; 

4)现在我们可以调用后面从代码,用户控件,并加入到我们的RibbonWindow。

tab1.Items.Add(new UserControl1()); 

我还附上简单的示例此

http://www.syncfusion.com/downloads/support/directtrac/general/ze/WPfRibbonSample-1343767783

相关问题