... <igRibbon:RibbonGroup Caption="Data"> <igRibbon:RibbonGroup.DialogBoxLauncherTool> <igRibbon:ButtonTool Id="btnSaveDialog" Click="btnSaveDialog_Click" /> </igRibbon:RibbonGroup.DialogBoxLauncherTool> </igRibbon:RibbonGroup> ...
A Ribbon Group can show a small button called a DialogBoxLauncher on the right side of the Ribbon Group’s caption. As the name suggests, this button is primarily used to show a dialog or task pane related to the application tasks in that Ribbon Group.
You must set the Ribbon Group’s DialogBoxLauncherTool property to an instance of a ButtonTool.
You will display a DialogBoxLauncher button in a Ribbon Group. You will then use this DialogBoxLauncher to launch a SaveFileDialog.
Declare a DialogBoxLauncherTool in a RibbonGroup.
Create an instance of a ButtonTool in the DialogBoxLauncherTool tags.
Set the Id property of the ButtonTool to btnSaveDialog. You can use the Id and the xamRibbon™ control’s GetToolById method to get a reference to the ButtonTool in the code-behind.
Attach a click event handler to the ButtonTool. The sample code below uses a method named btnSaveDialog_Click to handle the ButtonTool’s click event.
In XAML:
... <igRibbon:RibbonGroup Caption="Data"> <igRibbon:RibbonGroup.DialogBoxLauncherTool> <igRibbon:ButtonTool Id="btnSaveDialog" Click="btnSaveDialog_Click" /> </igRibbon:RibbonGroup.DialogBoxLauncherTool> </igRibbon:RibbonGroup> ...
In the code-behind, create a method named btnSaveDialog_Click. In this method, instantiate a SaveFileDialog and show it.
In Visual Basic:
Private Sub btnSaveDialog_Click(ByVal sender As System.Object, _ ByVal e As System.Windows.RoutedEventArgs) Dim dialog As New Microsoft.Win32.SaveFileDialog() If dialog.ShowDialog() = True Then ' TODO: Add File Saving logic End If End Sub
In C#:
private void btnSaveDialog_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.SaveFileDialog dialog = new Microsoft.Win32.SaveFileDialog(); if(dialog.ShowDialog() == true) { // TODO: Add file saving logic } }
Run the application and click the DialogBoxLauncher button in the Ribbon Group with the caption Data.