I'm trying to figure out how to build a recursive binding in xaml. I know about HierarchialDataTemplate, but that's not what I want, because my data source is not a collection of items. Specifically, I'm building an exception browser, and am trying to figure out the best way of expressing the exception's InnerException field (which is of course another exception, hence recursion.)
This exception browser is part of a log viewer I'm building. Here is the XAML for the ListView so far:
<ListView x:Name="LogViewerOutput">
<ListView.ItemTemplate>
<DataTemplate DataType="Ushanka.Log.LogMessageEventArgs">
<Expander Style="{StaticResource ExceptionTreeStyle}" Width="Auto">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<Image Stretch="Fill" Width="16" Height="16" Margin="5"
Source="{Binding Path=Level, Converter={StaticResource LogLevelIconConverter}}" />
<TextBlock Text="{Binding Message}" />
</StackPanel>
</Expander.Header>
<Expander.Content>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Exception.Message}" />
<TextBlock Text="{Binding Exception.Source" />
<!-- Here I would like to somehow be able to recursively browse through the tree of InnerException -->
</StackPanel>
</Expander.Content>
</Expander>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Any ideas? Is this even possible?