我正在尝试在WPF中绘制一些实体。我的集合包含System.Drawing.Rectangle对象。当我尝试在WPF XAML中访问这些对象的位置时,我会得到以下错误:
“无法创建默认转换器以执行类型'System.Drawing.Point'和'System.Windows.Point'之间的单向转换。考虑使用Binding的Converter属性”
我知道我必须使用一些值转换器。您能指导我如何将'System.Drawing.Point'转换为'System.Windows.Point'吗?
更新:
以下代码会产生一些异常。
XAML:
“无法创建默认转换器以执行类型'System.Drawing.Point'和'System.Windows.Point'之间的单向转换。考虑使用Binding的Converter属性”
我知道我必须使用一些值转换器。您能指导我如何将'System.Drawing.Point'转换为'System.Windows.Point'吗?
更新:
以下代码会产生一些异常。
public class PointConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
System.Windows.Point pt = (Point)(value);
return pt;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
XAML:
<PathFigure StartPoint= "{Binding BoundingRect.Location, Converter={StaticResource PointConverter}}">