Hi guys,
So I am working on a routine that validates and imports some data between two systems.
both routines output their results into a list of objects and I am trying to bind to this list in my GUI.
What I would like to achieve is that each type of result, be it a validation result or an import result to have its own data template.
For example:
Validation result should look like this:
Number : Result
And import result should look like this:
Source No: Imported No: Printed
The issue I have is that my data template does not appear to be selected and I'm not sure why.
<ListView ItemsSource="{Binding Path=Results}">
<ListView.Resources>
<DataTemplate DataType="{x:Type customTypes:ValidationResult}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=InvoiceNumber}" />
<TextBlock Text="{Binding Path=ResultString}" />
</StackPanel>
</DataTemplate>
</ListView.Resources>
</ListView>
I'm sure I am missing something obvious, but I'm not sure what.
At this time I have only devised the data template for the ValidationResult, but this is because only validation is currently adding its results to the Results collection.
-----------------------------------------
Refinement
Just to add some additional information here.
I might have a results list that looks like this:
ValidationResult
ValidationResult
ImportResult
ImportResult
My list view is bound to a property of type
ReadOnlyCollection<object>
which contains the result list.
My data template shown above is one of two different templates I want to use when displaying the items. However, at this time, even that single template is not displaying data. I have a listview, that clearly has items in as there are selectable items shown on screen, however they do not use the templates and I'm not sure why.