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..
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.