也许这里已经是这样的问题,但我没有找到它.
我有MVVM应用程序,并且ViewModel我必须对某些属性的更改执行一些其他操作(例如,如果View更改它们).哪种方法更好,为什么?
1st - 添加AdditionalAction对setter的调用
public class ViewModel: INotifyPropertyChanged
{
private int _MyProperty;
public int MyProperty
{
get { return _MyProperty; }
set
{
if (_MyProperty == value) return;
_MyProperty = value;
RaisePropertyChanged(() => MyProperty);
// --- ADDITIONAL CODE ---
AdditionalAction();
}
}
}
Run Code Online (Sandbox Code Playgroud)
第二 - 自我订阅INotifyPropertyChanged
public class ViewModel: INotifyPropertyChanged
{
public ViewModel()
{
// --- ADDITIONAL CODE ---
PropertyChanged += OnPropertyChanged;
}
private int _MyProperty;
public int MyProperty
{
get { return …Run Code Online (Sandbox Code Playgroud) ComVisibleregasm /codebase "assembly_path"MyAssemblyName.dll.config)在程序集的文件夹中ConfigurationManager.AppSettings["SettingName"]CreateObject("...")ConfigurationManager.AppSettings["SettingName"]返回null.它看起来像程序集没有看到配置文件.我应该怎么做才能使它可行?
我有ComVisible类的.NET程序集.几天前(我可以通过git找到那个时刻发生的事情) - Excel不再看到这个类了.所以:
我有界面
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface MyInterface { ... }
Run Code Online (Sandbox Code Playgroud)
和班级
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
[ProgId("MyClass.Id")]
public class MyClass { ... }
Run Code Online (Sandbox Code Playgroud)
Excel通过创建实例
Dim c as MyClass
Set c = New MyClass
Run Code Online (Sandbox Code Playgroud)
之前一切都像魅力一样,但删除了一些方法(从界面和类)后,Excel很疯狂 - 它给我一个错误Class doesn't support Automation or does not support expected interface.哪里可以成问题?