Textblock and button is not shown in the Tabcontrol

Topics: Prism v4 - Silverlight 4
Jun 20, 2011 at 9:53 AM

Hi All,

I'm loading the module to the tabcontrol using Prism region. Modules are loading fine. But I have textblock and button as a tab item header which is not shown in the UI when modules loaded in the region.

  <sdk:TabControl x:Name="MaintabControl" regions:RegionManager.RegionName="MainTabRegion" toolkit:DockPanel.Dock="Bottom" Margin="0,30,0,0" >
            <sdk:TabControl.ItemTemplate>
                <DataTemplate>
                    <toolkit:WrapPanel>
                        <TextBlock Name="tabHeader" Text="A Tab" VerticalAlignment="Center" />
                        <Button Margin="3,2,2,2"  VerticalAlignment="Center">X</Button>
                    </toolkit:WrapPanel>
                </DataTemplate>
            </sdk:TabControl.ItemTemplate>
</sdk:TabControl>

Please let me know where I'm wrong?


Regards

 Mahesh

 

Jun 20, 2011 at 1:42 PM

hello

 

i think you have to set your textblock thing on the headertemplate that normally should be available on the tabitem level

 

Jun 21, 2011 at 8:00 AM

Hi,

<sdk:TabControl x:Name="MaintabControl" regions:RegionManager.RegionName="MainTabRegion" toolkit:DockPanel.Dock="Bottom" Margin="0,30,0,0" MouseLeftButtonUp="MaintabControl_MouseLeftButtonDown">
            <sdk:TabControl.ItemTemplate>
                <sdk:HeaderedItemsControl>
                    <toolkit:WrapPanel>
                        <TextBlock Name="tabHeader" Text="A Tab" VerticalAlignment="Center" />
                        <Button Margin="3,2,2,2"  VerticalAlignment="Center">X</Button>
                    </toolkit:WrapPanel>
                </sdk:HeaderedItemsControl>
                <DataTemplate>

                </DataTemplate>
            </sdk:TabControl.ItemTemplate>
        </sdk:TabControl>

If I give like above, getting error that we can't add sdk:HeaderItemsControl inside the ItemTemplate. I want to display the textblock and button in each tabitem. I don't want to write code in the cs file. I need some solution in xaml itself. Because I'm binding the modules in the region that's why.

Regards

Mahesh

Jun 21, 2011 at 8:19 AM

hello

 

can you post a functional sample repro that i can test ?

 

Thanks

Jun 21, 2011 at 12:09 PM

Hi,

Can I have your mail id? I will send the sample file to you.

Thanks

Jun 21, 2011 at 2:40 PM

Hi

 

im sorry im able to compile but not to run your application on my current machine

anyway

 

check this

 

        <sdk:TabControl x:Name="MaintabControl" regions:RegionManager.RegionName="MainTabRegion" toolkit:DockPanel.Dock="Bottom" Margin="0,30,0,0" MouseLeftButtonUp="MaintabControl_MouseLeftButtonDown">
            <sdk:TabControl.Resources>
                <Style TargetType="TabItem">
                    <Setter Property="HeaderTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <toolkit:WrapPanel>
                                    <TextBlock Name="tabHeader" Text="A Tab" VerticalAlignment="Center" />
                                    <Button Margin="3,2,2,2"  VerticalAlignment="Center">X</Button>
                                </toolkit:WrapPanel>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </sdk:TabControl.Resources>
        </sdk:TabControl>

Jun 22, 2011 at 6:21 AM

Hi,

Still I'm not getting the textblock and button in the tabitem header. It works fine in the WPF but not in the Silverlight.

Thanks

Mahesh