0

I have a WPF Ribbon based application and a DLL.

In the application I uses a third party source (Syncfusion) to create my RibbonWindow.

The DLL is a WPF class library that consist of a UserControl which is a RibbonBar.

I would like to add that UserControl to my RibbonWindow.

I'm not sure how to do that programmatically.

MainWindow.xaml.cs

Dynamically loaded the UserControl from the 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.xaml.cs

        public void MainWindow()
    {
        InitializeComponent();
    }

How can I get the RibbonBar from WX.UserControl (Bar1) into (Tab1)?

Thanks.

dov
  • 27
  • 7

1 Answers1

1

1)If we need to programmatically add UserControl which is a RibbonBar to your RibbonWindow, your UserControl should be like below

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)Refer the assembly file in your application.

3)use that Assembly in code behind like below

using WPFClassLibrary;

4)now we can call that UserControl from code behind and add to the our RibbonWindow.

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

i have also attach simple sample for this

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