I have a class, which looks like
public class MyClass
{
public string MyTitle{get;set;}
public MyClass Child{get;set;
}
The reason for this is there will only ever be a 1 to 1 relationship between child and parent (meaning, no parent will have multiple children).
I want to lay this out in a WPF application, where each MyTitle
will be displayed horizontally (based upon how many parent and children there are in total). EG, something like
MyClass.MyTitle MyClass.Child.MyTitle MyClass.Child.Child.MyTitle etc
In the web world we can add loops and if statements, simply checking if the child is null (or not) and then appending the next item.
In the web world, something like (psuedo code)
item = Model.MyClass;
do while(true) {
if (item != null) {
<div class="floatLeft">item.MyTitle</div>
}
else {
break;
}
item = parent.Child;
}
XAML appears to limit me to Templates. Whilst I'm sure I'd work out a C# solution and then bind directly, I'm using this as an opportunity to learn more about XAML.
The problem is, it isn't a list so I'm not sure if using ItemsControl/ListView/etc is the correct approach. I'm not even sure if what I want can be done.
So my question is simply can this be done using XAML only?