如何获取已执行的Ribbon命令标签。信息存在于发送方对象中,但如何在RibbonCommand中进行转换,然后我可以获取该命令名称
private void RibbonCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
RibbonCommand rbnCmd = sender as RibbonCommand;
}
但在这种情况下,rbnBmd仍然是空的。如何将发送方对象转换为功能区命令?
答案 0 :(得分:0)
在这里你走人
private void RibbonCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
MainWindow m = (MainWindow)sender;
RibbonGroup rbnGrp = m.DiscoveryGroup;
RibbonCommand rbnCmd = (RibbonCommand)rbnGrp.Command;
string clickedCmd = rbnCmd.LabelTitle;
MainWindow是你的类,扩展Window意味着MainWindow:Window 正式你的Window1