【发布时间】:2020-04-14 18:40:00
【问题描述】:
在通用 Windows 应用程序的上下文中,我有以下类(位于 .NET Standard 库中):
public class Store
{
ICollection<string> Products { get; set; } = new List<string>();
}
以及以下 XAML
<DataContext>
<local:Store Products="Banana, Orange, Lemmon">
<DataContext>
显然,当我编译它时,XamlCompiler 抱怨,因为它不知道如何将字符串转换为 ICollection
我的问题是:
有没有办法扩展 XamlCompiler 以使其了解如何将逗号分隔的字符串转换为ICollection<string>?
我看到有一个编译时属性:
CreateFromStringAttribute,但我不能在我的 Store 类中使用,因为它位于 .NET Standard 类库中。
【问题讨论】:
标签: c# .net xaml uwp win-universal-app