【发布时间】:2012-07-01 14:55:35
【问题描述】:
我的工作
创建一个用户控件,它的 DependencyProperty 之一绑定到字符串数组
public static readonly DependencyProperty TaskListProperty =
DependencyProperty.Register("TaskList",
typeof(string[]),
typeof(MainControl),
null);
public string TaskList
{
get { return (string[])GetValue(TaskListProperty); }
set { SetValue(TaskListProperty, value); }
}
我得到了什么
此代码有错误
get { return (string[])GetValue(TaskListProperty); }
错误:无法将类型'string[]'隐式转换为'string'
如何
为什么会出现这个错误,我没有将它的源类型注册到字符串数组吗?如何解决?
【问题讨论】:
-
您的资源类型必须是
string[],而不是string。
标签: c# silverlight windows-phone-7 data-binding dependency-properties