get RibbonCommand Name from sender Object that is executed
How to get the Label of Ribbon command that is executed. Information is present in sender object but how to cast it in RibbonCommand and then I can get that command name
private void RibbonCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
RibbonCommand rbnCmd = sender as RibbonCommand;
}
But in this case r开发者_C百科bnBmd remains empty. How to cast sender object into ribbon command ?
Here You Go Man
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 is your class that extends Window means MainWindow:Window formally your Window1
精彩评论