Hello,
I am writing a testapplication in C# using WPF, but got a problem with binding the tabcontrol.
My scenario is as follows:
I have created an custom object called TestCategory this object has a collection of TesttableParts (TesttablesCollection). Now I want to show a tab for every TestCategory, for every testtablepart in the collection of the TestCatecory there should be a string with a result displayed on the tab. I created a ItemTemplate for the string and the result of the TesttablePart. I got this working without a problem.
But now I want to change the ItemTemplate of the TesttablePart with an other one based on a property (ResultPresentationTypeEnum) of my TesttablePart, I have writen the below code but the binding does not work correctly.
<TabControl.ContentTemplate><DataTemplate><ItemsControl ItemsSource="{Binding TesttablesCollection}" Margin="20"><ItemsControl.ItemsPanel><ItemsPanelTemplate><WrapPanel Orientation="Vertical" /></ItemsPanelTemplate></ItemsControl.ItemsPanel><ItemsControl.Style><Style TargetType="ItemsControl"><Style.Triggers><DataTrigger Binding="{Binding Path=ResultPresentationTypeEnum}"><DataTrigger.Value><etafResults:ResultPresentationType>BOOL</etafResults:ResultPresentationType></DataTrigger.Value><Setter Property="ItemTemplate" Value="{StaticResource BoolTestPartTemplate}"/></DataTrigger><DataTrigger Binding="{Binding Path=ResultPresentationTypeEnum}"><DataTrigger.Value><etafResults:ResultPresentationType>VALUE</etafResults:ResultPresentationType></DataTrigger.Value><Setter Property="ItemTemplate" Value="{StaticResource ValueTestPartTemplate}"/></DataTrigger></Style.Triggers></Style></ItemsControl.Style></ItemsControl></DataTemplate></TabControl.ContentTemplate>
This template gives me a binding error stating that the ResulPresentationTypeEnum property in the DataTriggers, cant be found on the TestCategory object. But the property should be bound to the particular instance in the TesttablesCollection (the ItemsSource), this is a TesttablePart instance.
How can I change the bindings so that it point to the TesttablePart instance of the TesttablesCollection rather than the parent TestCategory object to which the collection belongs.
Any help would be greatly appreciated.
Marcel