安装 Visual Studio 2012 并打开 Silverlight 5 项目后,我遇到了与 TypeConverter 相关的各种设计时错误,例如:
The TypeConverter for "FontWeight" does not support converting from a string.
The TypeConverter for "Point" does not support converting from a string.
The TypeConverter for "Thickness" does not support converting from a string.
但是,这并不是一个详尽的列表。
这些例子是:
<Setter Property="FontWeight" Value="Bold" />
<RadialGradientBrush GradientOrigin="0.5,0.5"> ...
<Setter Property="Padding" Value="0" />
我在这里遗漏了一些明显的东西,还是这是一个错误?
最佳答案
我遇到了同样的问题:在资源部分中定义
<UserControl.Resources>
<local:MyConverter x:Key="myConverter"/>
</UserControl.Resources>
在 XAML UE 中,我必须进行更改
...Width="{Binding BindingProperty, Converter=myConverter}"...
至
...Width="{Binding BindingProperty, Converter={StaticResource myConverter}..."
关于.net - "FontWeight"的 TypeConverter 不支持从字符串转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12004592/