views:

49

answers:

0

I have a collection of objects which contains a child collection. I can get the parent collection to show properly on the tabs. But I cannot get the child collection to show in the content pane.

here is my XAML:

<d:DataContext>
        <Binding Source="{StaticResource SearchResultsViewModel}" />
    </d:DataContext>

<TabControl TabStripPlacement="Left"
    ItemsSource="{Binding DoctorsList}">
        <TabControl.ItemTemplate>
            <DataTemplate>
                <StackPanel>
                    <TextBlock Text="{Binding Path=DisplayName}"
                               FontSize="14"
                               FontWeight="Bold"
                               HorizontalAlignment="right" />
                    <TextBlock Text="{Binding Path=DoctorLicense.NPINumber,StringFormat={}NPI Number: {0}}"
                               FontSize="10"
                               FontStyle="Italic"
                               HorizontalAlignment="Right" />
                </StackPanel>
            </DataTemplate>
        </TabControl.ItemTemplate>
        <TabControl.ContentTemplate DataContext="{Binding /DoctorOffices}">
            <DataTemplate>
                <StackPanel>
                    <TextBlock Text="{Binding Path=DisplayName}"
                               FontSize="14"
                               FontWeight="Bold"
                               HorizontalAlignment="right" />
                    <TextBlock Text="{Binding Path=DoctorLicense.NPINumber,StringFormat={}NPI Number: {0}}"
                               FontSize="10"
                               FontStyle="Italic"
                               HorizontalAlignment="Right" />
                </StackPanel>
            </DataTemplate>
        </TabControl.ContentTemplate>

    </TabControl>

I can mess around and get it to show in Blend but it wont show in VS. I can switch around my doctorList or Office list and they will show up correctly in the tabs in both Blend and VS when run(ie live data). But I cant get one to show in the tabs and the child in the content pane. I have tried several different methods including HeaderTemplate and ContentTemplate. I can feel I am almost there, just missing some little detail. Thanks for the help.

EDIT

Actually I have fixed the above..but I am still having a problem:

<Style x:Key="TabItemStyle"
               BasedOn="{StaticResource {x:Type TabItem}}"
               TargetType="{x:Type TabItem}">
            <Setter Property="Content"
                    Value="{Binding DoctorOffices/}" />
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <ListBox ItemsSource="{Binding}">
                            <Border BorderBrush="Black"
                                    BorderThickness="1"
                                    Margin="2,10,2,0"
                                    CornerRadius="5"
                                    Padding="10,5,10,5">
                                <StackPanel>
                                    <TextBlock>
                        <TextBlock.Inlines>
                            <Run Text="Physican ID: "
                                            FontWeight="Normal"
                                            FontSize="10" />
                            <Run Text="{Binding Path=ForeignID}"
                                            FontWeight="Bold"
                                            FontSize="14" />
                        </TextBlock.Inlines>
                                    </TextBlock>
                                    <TextBlock Text="{Binding OfficeDisplayName}" />
                                    <TextBlock Text="{Binding Address1}" />
                                    <TextBlock Text="{Binding Address2}" />
                                    <TextBlock Text="{Binding Address3}" />
                                    <TextBlock>
                    <TextBlock.Inlines>
                        <Run Text="{Binding Path=City,StringFormat={}{0}\,}" />
                        <Run Text="{Binding Path=State,StringFormat={}{0}\ \ }" />
                        <Run Text="{Binding Zip}" />
                    </TextBlock.Inlines>
                                    </TextBlock>
                                </StackPanel>
                            </Border>
                        </ListBox>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>

Now the issue is that in my listbox, I am only getting one item, instead of the collection even though I know that there are more than one item in my collection. I have a feeling that this may be because its a content control, and its only reading the first item...would that be correct? How would I fix this?

EDIT 2...OI I bet I am going to need a separate DataTemplate for the listbox inside my datatemplate..crikey...ok...maybe tomorrow.