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

RadTabControl items template

8 Answers 197 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Riccardo
Top achievements
Rank 1
Riccardo asked on 08 Oct 2009, 11:03 AM
I create an object MyTabControl that heritage RadTabControl. I'd like to insert in my generic.xaml a theme to customize all RadTabItem of my MyTabControl.

I tried to use this suggestions:
http://www.telerik.com/help/silverlight/radtabcontrol-styling.html

But it works directly in user control (xaml): I haven't it 'cause mu MyTabControl has been defined on a pure .cs, on a Library Class.

8 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 12 Oct 2009, 09:32 AM
Hello Riccardo,

Please check these articles to get acquainted with how to create custom controls:
http://www.silverlightshow.net/items/Creating-a-Silverlight-Custom-Control-The-Basics.aspx
http://msdn.microsoft.com/en-us/library/cc278064(VS.95).aspx

Best wishes,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Riccardo
Top achievements
Rank 1
answered on 12 Oct 2009, 11:11 AM
Thanks Valentin, I'm checking it!
0
Riccardo
Top achievements
Rank 1
answered on 12 Oct 2009, 02:27 PM
Hi Valentine, I've checked and studied that link. All works good in external resource file, but I can't do it in generic.xaml redefining style for an object.

I create MyRadTabControl : RadTabControl

In generic.xaml I defined style for that object and in MyRadTabControl consturctor I wrote:

DefaultStyleKey =

typeof(EsaTabControlC1);

But when I debug, it gives an error in last row of object (</SilverlightClassLibrary1:EsaTabControlC1> ) in xaml:

 

<UserControl  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
    xmlns:SilverlightClassLibrary1="clr-namespace:SilverlightClassLibrary1;assembly=SilverlightClassLibrary1" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    x:Class="DemoTabControl.MainPage" 
    Width="640" Height="480" mc:Ignorable="d">  
 
    <Grid x:Name="LayoutRoot" Background="White">  
        <Grid> 
            <!--<SilverlightClassLibrary1:EsaTabControl d:LayoutOverrides="Width, Height" Style="{StaticResource EsaTabControlStyle1}">  
                <SilverlightClassLibrary1:EsaTabItem Header="FirstItem">  
                    <TextBlock HorizontalAlignment="Left" Text="Mi piacerebbe diventare famoso." TextWrapping="Wrap" d:LayoutOverrides="Height"/>  
                </SilverlightClassLibrary1:EsaTabItem> 
                <SilverlightClassLibrary1:EsaTabItem Header="SecondItem">  
                    <TextBlock HorizontalAlignment="Left" Text="Cerco amico per gite in bicicletta." TextWrapping="Wrap"/>  
                </SilverlightClassLibrary1:EsaTabItem> 
                <SilverlightClassLibrary1:EsaTabItem Header="ThirdItem">  
                    <TextBlock HorizontalAlignment="Left" Text="Voglio vendere casa. Cosa mi consigliate?" TextWrapping="Wrap"/>  
                </SilverlightClassLibrary1:EsaTabItem> 
            </SilverlightClassLibrary1:EsaTabControl>--> 
            <SilverlightClassLibrary1:EsaTabControlC1 d:LayoutOverrides="Width, Height" > 
                <SilverlightClassLibrary1:EsaTabItem Header="FirstItem">  
                    <TextBlock HorizontalAlignment="Left" Text="Mi piacerebbe diventare famoso." TextWrapping="Wrap" d:LayoutOverrides="Height"/>  
                </SilverlightClassLibrary1:EsaTabItem> 
                <SilverlightClassLibrary1:EsaTabItem Header="SecondItem">  
                    <TextBlock HorizontalAlignment="Left" Text="Cerco amico per gite in bicicletta." TextWrapping="Wrap"/>  
                </SilverlightClassLibrary1:EsaTabItem> 
                <SilverlightClassLibrary1:EsaTabItem Header="ThirdItem">  
                    <TextBlock HorizontalAlignment="Left" Text="Voglio vendere casa. Cosa mi consigliate?" TextWrapping="Wrap"/>  
                </SilverlightClassLibrary1:EsaTabItem> 
            </SilverlightClassLibrary1:EsaTabControlC1> 
        </Grid> 
    </Grid> 
</UserControl> 

0
Miroslav
Telerik team
answered on 16 Oct 2009, 12:04 PM
Hi Riccardo,

I am sorry for the delayed reply!

Have you also inherited the TabItems?

You need to inherit them as well and set their DefaultStyleKey accordingly.

Also please make sure that you override these two methods in the RadTabControl:

1. IsItemItsOwnContainer - in your case it should be implemented as:
return item is EsaTabItem

2. GetContainerForItemOverride - in your case it should be implemented as:
return new EsaTabItem();

Also the name of the inherited control should match the default style key type. I.e. you will need to have

EsaTabControl: RadTabControl

then the default style key also needs to be:

this.DefaultStyleKey = typeof(EsaTabControl)

What is the error message that you see when you run the application?

Kind regards,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Riccardo
Top achievements
Rank 1
answered on 16 Oct 2009, 01:55 PM
Hi Miroslav, sorry you too to me. I did it (generic.xaml). Now I'm trying your suggest about override two TabItemControl but I found a trouble:
I found "GetContainerForItemOverride" but I can't found "IsItemItsOwnContainer",
I have "IsItemItsOwnContainerOverride" instead...

Thank you very much.
Merlinox
0
Miroslav
Telerik team
answered on 20 Oct 2009, 08:16 AM
Hi Riccardo,

I am sorry for my error, I did indeed mean

IsItemItsOwnContainerOverride

Does this work for you?

Sincerely yours,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Riccardo
Top achievements
Rank 1
answered on 20 Oct 2009, 08:21 AM
Sorry but I don't understand what I need to insert in override method "IsItemItsOwnContainerOverride".
Thanks.
0
Miroslav
Telerik team
answered on 23 Oct 2009, 12:05 PM
Hello Riccardo,

In this method you specify what kind of visual children you expect the control to have.

In your case it seems that the class that inherits the RadTreeViewItem is called EsaTabItem, so the contents of the method will be:

return item is EsaTabItem;

Hopefully this will work in your case,

Best wishes,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
TabControl
Asked by
Riccardo
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Riccardo
Top achievements
Rank 1
Miroslav
Telerik team
Share this question
or