What I Do
create a user control which one of its DependencyProperty binds to a string array
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); }
}
What I got
a error for this code
get { return (string[])GetValue(TaskListProperty); }
Error:Cannot implicitly convert type ‘string[]’ to ‘string’
How
Why does this error happen, don’t I register its type of source to string array? How to solve it?
The error message is right. You forgot the
[]for your property type.