I'm using the WPF Ribbon Application Menu:
https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11877
https://msdn.microsoft.com/de-de/library/ff799534(v=vs.110).aspx
How can I close the Application (File) Menu programmatically?
How can I detect if the user opens the Application Menu? I didn't found an appropriated event
You need IsDropDownOpen
property and related event(s). XAML (this is for .NET 4.5+, but for 4.0 it will be almost the same, the difference will be in namespace prefix):
<StackPanel>
<Ribbon>
<Ribbon.ApplicationMenu>
<RibbonApplicationMenu x:Name="Menu" DropDownOpened="RibbonApplicationMenu_DropDownOpened">
<RibbonApplicationMenuItem Header="Foo"/>
<RibbonApplicationMenuItem Header="Bar"/>
</RibbonApplicationMenu>
</Ribbon.ApplicationMenu>
</Ribbon>
</StackPanel>
Code-behind:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void RibbonApplicationMenu_DropDownOpened(object sender, EventArgs e)
{
// user has opened menu
Debug.WriteLine("Menu opened.");
// let's close it from code
Menu.IsDropDownOpen = false;
}
}
Also, you may want to disable entire menu. This can be done using IsEnabled
property.
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.