0

I am new to WPF, I want create a project with ribbon window. I started new project and started with new window with ribbon control. What I want is, when user click on a button in ribbon control, I need to add another window as a tab instance in my main window under the ribbon control like we see in office word (new document) and Photoshop etc. How to achieve this behavior, I searched on google and I found a lot of tutorials how to add ribbon control not going further. any one help me..

user1870056
  • 73
  • 2
  • 8

1 Answers1

0

In your RibbonWindow XAML, define a TabControl

<RibbonWindow>
  ...
  <TabControl Name="mainTabControl" />
</RibbonWindow>

Add an EventHandler to your RibbonButton:

<RibbonButton Name="newTabRibbonButton" Click="newTabRibbonButton_Click_1" />

private void newTabRibbonButton_Click_1(object sender, RoutedEventArgs e)
{
   TabItem newItem = new TabItem();
   newItem.Header = "New Document";
   mainTabControl.Items.Add(newItem);
}

Note however, that you need to define the Content for your TabItem.

dotnetzen
  • 166
  • 1
  • 9