此C#代码给我一个错误消息,该字符串不包含AddItem的定义。我尝试添加其他标识符,但我不知道是哪个标识符。
C#:
const string RIBBON_TAB = "HILLAM TAB";
const string RIBBON_PANEL = "Ribbon button";
public object ToolTip {
get;
private set;
}
public BitmapSource Png {
get;
private set;
}
// Both OnStartup and OnShutdown must be implemented as public method
public Result OnStartup(UIControlledApplication a) {
//get the ribbon tab
try {
a.CreateRibbonTab(RIBBON_TAB);
}
catch(Exception) {} //tab already exists
// Add a new ribbon panel
RibbonPanel panel = null;
List < RibbonPanel > panels = a.GetRibbonPanels(RIBBON_TAB);
foreach(RibbonPanel pnl in panels) {
if (pnl.Name == RIBBON_PANEL) {
panel = pnl;
break;
}
}
if (panel == null) {
panel = a.CreateRibbonPanel(RIBBON_TAB, RIBBON_PANEL);
}
// Create a push button to trigger a command add it to the ribbon panel.
string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;
PushButtonData buttonData = new PushButtonData("cmdHelloWorld", "Hello World", thisAssemblyPath, "RevitAddin1.HelloWorld");
PushButton pushButton = RIBBON_PANEL.AddItem(buttonData) as PushButton;
// Optionally, other properties may be assigned to the button
// a) tool-tip
pushButton.ToolTip = "Say hello world.";
我希望单击面板,它会打开一个新窗口,并显示以下消息:“问好世界”。