I'm using a XamTabControl in with an ItemsSource that uses a CompositeCollection. Based on the type of item for the tab, I want to use a different DataTemplate for the content. So I created a ContentTemplateSelector.
My problem is the ContentTemplateSelector never gets called. If I change from a XamTabControl to a base TabControl - selector gets called just fine. I think this is a bug, but if anyone has a workaround that would be great.
Thanks.
Upgraded to 11.1 and it works now. Thanks.
There was an issue with this recently fixed so try getting the latest hotfix.
Well, in my particular case I was using a Composite Collection, which your example does not utilize. So that might be a difference.
<TabControl x:Name="tabs" Grid.Row="1" TabStripPlacement="Left" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Padding="0" > <TabControl.Resources> <DataTemplate x:Key="ServiceStepTemplate"> <local:ServiceStepEditView ServiceStep="{Binding}"/> </DataTemplate> </TabControl.Resources> <TabControl.ItemTemplate> <DataTemplate> <Border CornerRadius="10"> <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <TextBlock Text="{Binding Description}" Foreground="{Binding Status, Converter={local:StepStatusToBrushConverter}}" x:Name="description" HorizontalAlignment="Right" VerticalAlignment="Center"/> </Grid> </Border> </DataTemplate> </TabControl.ItemTemplate> <TabControl.ContentTemplateSelector> <local:ServiceStepTemplateSelector/> </TabControl.ContentTemplateSelector> <TabControl.ItemsSource> <CompositeCollection> <TabItem Header="Call Info"> <StackPanel Orientation="Horizontal" Grid.IsSharedSizeScope="True"> <StackPanel Margin="10"> <corewpf:BOEditor Property="{Binding ProtocolCode}" ComboBoxList="{Binding Source={StaticResource protocolListProvider}}" /> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition SharedSizeGroup="Label" /> <ColumnDefinition SharedSizeGroup="Field" /> </Grid.ColumnDefinitions> <Label Grid.Column="0" Name="label" Target="{Binding ElementName=patientPicker}" >_Patient</Label> <local:PatientPicker x:Name="patientPicker" Grid.Column="1" PatientId="{Binding PatientId, Mode=TwoWay}" /> </Grid> <corewpf:BOEditor Property="{Binding CallDateTime}" /> <corewpf:BOEditor Property="{Binding OriginalCoordinatorCode}" ComboBoxList="{Binding Source={StaticResource coordinatorListProvider}}" /> <corewpf:BOEditor Property="{Binding CurrentCoordinatorCode}" ComboBoxList="{Binding Source={StaticResource coordinatorListProvider}}" /> <corewpf:BOEditor Property="{Binding SourceCode}" ComboBoxList="{Binding Source={StaticResource sourceListProvider}}"/> <corewpf:BOEditor Property="{Binding ReferringFacilityCode}" ComboBoxList="{Binding Source={StaticResource facilityListProvider}}" /> <corewpf:BOEditor Property="{Binding ReceivingFacilityCode}" ComboBoxList="{Binding Source={StaticResource facilityListProvider}}"/> <corewpf:BOEditor Property="{Binding CallerName}" /> <corewpf:BOEditor Property="{Binding ContactTypeCode}" ComboBoxList="{Binding Source={StaticResource contactTypeListProvider}}"/> <corewpf:BOEditor Property="{Binding ContactName}" /> <corewpf:BOEditor Property="{Binding PhoneTypeCode}" ComboBoxList="{Binding Source={StaticResource phoneTypeListProvider}}"/> <corewpf:BOEditor Property="{Binding Phone}" /> <corewpf:BOEditor Property="{Binding PhoneExtension}" TextMinWidth="50" /> <StackPanel Orientation="Horizontal"> <Button x:Name="CancelCallButton" Click="CancelCallClick" HorizontalAlignment="Left" IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=csla:ObjectStatus, AncestorLevel=1}, Path=IsNew, Converter={corewpf:BooleanNotConverter}}" > <AccessText>_Cancel Call</AccessText> </Button> <Button x:Name="ViewStatusChangesButton" Click="ViewStatusChanges" HorizontalAlignment="Left" IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=csla:ObjectStatus, AncestorLevel=1}, Path=IsNew, Converter={corewpf:BooleanNotConverter}}" > <Image Source="..\Icons\StatusHistory.png" Height="20" /> <Button.ToolTip> <ToolTip>View Status Change History</ToolTip> </Button.ToolTip> </Button> </StackPanel> </StackPanel> <StackPanel Margin="10"> <corewpf:BOEditor Label="Created By" Property="{Binding CreatedUser, Mode=OneWay}" IsReadOnly="True" /> <corewpf:BOEditor Label="Created On" Property="{Binding CreatedDate, Mode=OneWay}" IsReadOnly="True" /> <corewpf:BOEditor Label="Modified By" Property="{Binding ModifiedUser, Mode=OneWay}" IsReadOnly="True" /> <corewpf:BOEditor Label="Modified On" Property="{Binding ModifiedDate, Mode=OneWay}" IsReadOnly="True" /> </StackPanel> </StackPanel> </TabItem> <CollectionContainer Collection="{Binding Source={StaticResource dataProvider}, Path=Steps}" /> <TabItem Header="Notes"> <Grid> <corewpf:NoteEditView Name="notes" KeyboardNavigation.TabNavigation="Cycle" NoteEditList="{Binding Notes}"/> </Grid> </TabItem> </CompositeCollection> </TabControl.ItemsSource> </TabControl>
Hello,
I put together a sample to test the ContentTemplateSelector and in my sample it works when using the XamTabControl. Please take a look at my sample to see if I am doing something different or if my sample reproduces the issue in your environment.
Let me know if you have any questions with this matter.
I have same problem with XamTabControl
It does not work
<igWindows:XamTabControl ItemsSource="{Binding Items}" ContentTemplateSelector="{StaticResource TemplateSelector}" />
This is works fine
<TabControl ItemsSource="{Binding Items}" ContentTemplateSelector="{StaticResource TemplateSelector}"/>