【问题标题】:get RibbonCommand Name from sender Object that is executed从执行的发送者对象中获取 RibbonCommand 名称
【发布时间】:2010-12-08 16:41:49
【问题描述】:

如何获取执行的 Ribbon 命令的标签。信息存在于发件人对象中,但如何在 RibbonCommand 中进行转换,然后我可以获得该命令名称

 private void RibbonCommand_Executed(object sender, ExecutedRoutedEventArgs e)
    {
RibbonCommand rbnCmd = sender as RibbonCommand;
}

但在这种情况下 rbnBmd 保持为空。如何将发件人对象转换为功能区命令?

【问题讨论】:

    标签: wpf command casting ribbon sender


    【解决方案1】:

    你来了

      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

    【讨论】:

    • 但是如何获得 X:key of clicked command ?仍然是一个问题 ''
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-30
    • 1970-01-01
    相关资源
    最近更新 更多