Hi @834939691 ,
Could you provide a fully functional, yet minimal, macro embedded in the sample model or Visual Studio solution? It should include an add-in manifest, allowing for easy compilation, loading, running, and debugging with just a single click, enabling live analysis of its behavior in the sample model.
Please do not share any confidential information.
System.Windows.Application.Current 是 WPF 应用程序中的一个静态属性,它返回当前正在运行的Application实例。Application类是应用程序的入口点和生命周期管理的核心部分,负责启动、配置和管理整个应用程序的生命周期。
Revit 插件是嵌入在 Revit 环境中的,而不是作为独立的 WPF 应用程序运行,所以这个Application示例是null。
我看你的代码主要是想修改窗口的主题,在修改完ResourceDiction之后,只需要将
`System.Windows.Application.Current.Resources = resources;`改为`this.Resources = resources;`即可。如果你想批量修改,可以让你的用户控件,窗口等继承一个基类,在基类中修改主题。