I took Daniel's answer and made an example out of it. I thought posting the code might be helpful:
<Window x:Class="SampleWpfApplication.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:SampleWpfApplication="clr-namespace:SampleWpfApplication">
<Window.Resources>
<DataTemplate DataType="{x:Type SampleWpfApplication:Result}">
<Label>Simple Result</Label>
</DataTemplate>
<DataTemplate DataType="{x:Type SampleWpfApplication:AssertionFailedResult}">
<Label>Assertion Failed!</Label>
</DataTemplate>
</Window.Resources>
<ContentControl x:Name="contentControl" Content="{Binding Path=Result}" />
</Window>
Next, a model class that is the data context of the window:
public class Model
{
public Result Result { get; set; }
}
And in the MainWindow, I set the DataContext as follows:
DataContext = new Model()
{
Result = new AssertionFailedResult()
{
Success = false,
Description = "Assertion failed",
Expected = "1",
Actual = "1"
}
};
So with the DataTemplate, wpf knows how to render the control without any additional direction on my part. Thanks again, Daniel.