This is a migrated thread and some comments may be shown as answers.

update tab header

2 Answers 78 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Jingmeng
Top achievements
Rank 1
Jingmeng asked on 11 Aug 2010, 11:13 PM
hi everyone,
i have a problem on changing tab header, what i did is bind header textblock with a property of a C# object, but once i modify the property, the textblock(tab header) did change
code is looks like :
    radTab.ItemContainerStyle = App.Current.Resources["TabItemStyle"] as Style;
    radTab.ItemsSource = TabCollection;
 
TabCollection.add(new TabItem(){Header = "aa", IconPath = "~/Images/Icon1.png", Content = object})
xaml looks like:
<Style x:Key="TabItemStyle" TargetType="telerikNavigation:RadTabItem">
    <Setter Property="HeaderTemplate" >
        <Setter.Value>
            <DataTemplate x:Key="TabHeader">
                <StackPanel Orientation="Horizontal"  >
                   <Image x:Name="HeaderIcon" Source="{Binding IconPath, Mode=TwoWay}" Margin="3, 0, 3, 0" Width="40" Height="20"/>
                   <TextBlock x:Name="HeaderText" Text="{Binding Header, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </StackPanel>
            </DataTemplate>
        </Setter.Value>
    </Setter>
    <Setter Property="Height" Value="35" />
    <Setter Property="MaxWidth" Value="300" />
    <Setter Property="MinWidth" Value="120" />
    <Setter Property="ContentTemplate">
        <Setter.Value>
            <DataTemplate>
                <controlsToolkit:DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <ContentPresenter Content="{Binding Content}"/>
                </controlsToolkit:DockPanel>
            </DataTemplate>
        </Setter.Value>
    </Setter>
</Style>


once i go change tabItemCollection, tab header remain the same, any suggest how can i update?

best regards
MENG

2 Answers, 1 is accepted

Sort by
0
Accepted
Miroslav
Telerik team
answered on 16 Aug 2010, 02:14 PM
Hello Jingmeng,

Yout xaml code looks correct.

Can you confirm that the TabItem class implements INotifyPropertyChanged and that the PropertyChanged event is raised in the setter of the "Header" property?

If this is not the case then the binding will not update.

All the best,
Miroslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jingmeng
Top achievements
Rank 1
answered on 19 Aug 2010, 04:28 AM
hey Miroslav,
thanx for your help, it's working good now!!

best regards
Meng 
Tags
TabControl
Asked by
Jingmeng
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Jingmeng
Top achievements
Rank 1
Share this question
or