向应用程序中添加静态类.资源的错误

本文关键字:资源 错误 静态类 添加 应用程序 | 更新日期: 2023-09-27 18:07:17

我试图在Application.Resources中添加静态类作为资源

namespace MultiResImageChooser
{
public static class MultiResObjectInstance
{
    private static MultiResPropertyChanged multiResObject = new MultiResPropertyChanged();
    public static MultiResPropertyChanged current
    {
        get
        {
            return multiResObject;
        }
    }
   }
}

然后在app。xaml中有

 xmlns:static="clr-namespace:MultiResImageChooser"
 ....
<Application.Resources>
    <static:MultiResObjectInstance x:Key="MultiResObjectInstance"/>
</Application.Resources>`

但是在设计视图中,VS2012抱怨The type MultiResObjectInstance is an abstract and must include an explicit value

我如何正确地包括静态类在App.xaml作为资源?

向应用程序中添加静态类.资源的错误

请务必为它提供一个键,因为它是静态的。

你不能获得静态类的实例。

我认为问题已经是静态的了。XAML试图获取该类型的实例,但不能这样做,因此认为它是一个抽象…