Why are you making your life so hard? I mean there are many other ways to be a good programmer! I was just kidding.
You can simply write two "DataTemplate"
s and filter them based on their "DataType"
like this:
<Window.Resources>
<DataTemplate DataType="x:Type logic:AddressedRegisterInformation" ></DataTemplate>
<DataTemplate DataType="x:Type logic:NamedRegisterInformation" ></DataTemplate>
</Window.Resources>
<ListBox ItemsSource="{Binding}" />
Why don't you do this? instead of trying to use complicated custom "TemplateSelector"
that might cause you many problems like the one you mentioned. This way WPF will do all the selection things and you sit, bind an array of "Object"
to the "ItemsSource"
.
Hope it helps