I think it's because you're binding the TreeView
to your property that is a String
.
The tree expects a collection of some type, and finds a string
. It thinks, hey, I know what string
is ... it's a collection of chars
... and off he goes chopping marry and her poor lamb.
So, you either have to "box" your strings into a collection, or change your strategy :)
Edit: some more info, in case someone else stumbles upon this:
From MSDN: ItemsControl.ItemsSource Property :
[BindableAttribute(true)]
public IEnumerable ItemsSource { get; set; }
And having some fun with it:
var an_int = 4;
var a_string = "poor poor marry";
int[] an_array = new int[3] {1,2,3};
if (an_int is IEnumerable)
Console.WriteLine("you shouldn't see this");
if (a_string is IEnumerable)
Console.WriteLine("you should see this, as IEnumerable char");
if (an_array is IEnumerable)
Console.WriteLine("you should see this, as IEnumerable int");