RadTabControl items template

9 posts, 0 answers
  1. Riccardo
    Riccardo avatar
    36 posts
    Member since:
    Apr 2009

    Posted 08 Oct 2009 Link to this post

    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.
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 12 Oct 2009 Link to this post

    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.
  3. DevCraft banner
  4. Riccardo
    Riccardo avatar
    36 posts
    Member since:
    Apr 2009

    Posted 12 Oct 2009 Link to this post

    Thanks Valentin, I'm checking it!
  5. Riccardo
    Riccardo avatar
    36 posts
    Member since:
    Apr 2009

    Posted 12 Oct 2009 Link to this post

    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> 

  6. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 16 Oct 2009 Link to this post

    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.
  7. Riccardo
    Riccardo avatar
    36 posts
    Member since:
    Apr 2009

    Posted 16 Oct 2009 Link to this post

    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
  8. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 20 Oct 2009 Link to this post

    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.
  9. Riccardo
    Riccardo avatar
    36 posts
    Member since:
    Apr 2009

    Posted 20 Oct 2009 Link to this post

    Sorry but I don't understand what I need to insert in override method "IsItemItsOwnContainerOverride".
    Thanks.
  10. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 23 Oct 2009 Link to this post

    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.
Back to Top
DevCraft banner