考虑到这个
我得到了以下错误:
DataTemplate
:<DataTemplate x:DataType="Color">
...
</DataTemplate>
我得到了以下错误:
当你跟随这个错误时,它会带你去查看自动生成的视图代码,该代码使用了必须使用as运算符与引用类型或可空类型一起使用('Color'是一个非可空值类型)
as
运算符。public void DataContextChangedHandler(global::Windows.UI.Xaml.FrameworkElement sender, global::Windows.UI.Xaml.DataContextChangedEventArgs args)
{
global::Windows.UI.Color data = args.NewValue as global::Windows.UI.Color;
if (args.NewValue != null && data == null)
{
throw new global::System.ArgumentException("Incorrect type passed into template. Based on the x:DataType global::Windows.UI.Color was expected.");
}
this.SetDataRoot(data);
this.Update();
}
我知道{x:Bind}
是比较新的技术,但是有没有人知道如何配置它以允许值类型,或者至少使用直接转换?