How can I connect two TextBlocks with straight line or polyline TextBlocks are possitioned using StackPanels and they should be connected to make a tree. Should I use somehow data binding to ActualHeight Should I use Grid to allow layering of content Or am I forced to do layout myself without StackPanels
Thanks
Vojta
Here is very simplified XAML for illustration:
<StackPanel xmlns="http://schemas.microsoft.com/winfx/avalon/2005">
<StackPanel Orientation="Horizontal">
<Border >
<TextBlock Text="text"/>
</Border>
<StackPanel>
<StackPanel Orientation="Horizontal">
<Border >
<TextBlock Text="text"/>
</Border>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Border >
<TextBlock Text="text"/>
</Border>
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>

Connecting lines in hierarchical diagram
n3sachde
Marco Villagrana
Hello Vojta -
I'm not entirely clear on what you're trying to do. Could you clarify a bit more
gudel
Hello,
I want to present some hierarchical data such as XML, Organization Chart or (in my concrete case) XSD schema (like XML Spy). TreeView can present hierarchical data, but I think it cannot be customized to achieve such a diagram I wanted. My first idea was to use nested (recursive) vertical and horizontal StackPanels because they do required layout for me. So now I have positioned rectangles (each for one node in tree) but I don't know how to connect them with lines to form a diagram. There is no way how to obtain actual coordinates of each child (rectangle) from StackPanel. Probably I was little bit naive and I should make my own Panel which will layout not only my nodes but also lines between them.
Any suggestions how can I build diagrams which will represent XSD schemas (similar to XML Spy or similar to Organization Charts)
By the way Rectangles can be stretched to fill desired space but Lines doesn't offer such capability (they are always defined using coordinates). I miss something like HorizontalLine and VertiacalLine which can fill desired space (Rectangle with Height or Width set to zero is not the thing because lines can be dashed).
Thanks Vojta
Jagjot
I wanted to create custom control derived from ItemsControl, but I don't know how to specify ItemTemplate from C# and not from XAML. DataTemplate has property VisualTree of type FrameworkElementFactory and I don't know how to construct this factory. Is it possible to create FrameworkElementFactory without XAML code
Thanks
Vojta
chuchi
Hello Vojta -
It should be possible to get the coordinates of the elements to place lines between them. See the thread at http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=168894&SiteID=1 for more details. That said and depending on the structure of your data authoring a custom control to do this will probably be lighter weight.