ItemDropDownContentTemplate does not find display items name

2 posts, 0 answers
  1. Yann
    Yann avatar
    1 posts
    Member since:
    Dec 2011

    Posted 08 Dec 2011 Link to this post


    I try to display a list of UserControls in a RadTabControl and to use a UserControl property (name) to display tab header and dropdown items.

    According to this post (, I succeded in displaying Tab Header with UserControl "Name" property.
    To do this, I use a RelativeSource :




    ="{Binding DataContext.Name, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerik:RadTabItem}}"


    I have used your sample project (from post above) where I have modified MainWindow.xaml.cs file to create a list of UserControls :




    .radtabVariableControlsContainer.ItemsSource =




    Enumerable.Range(0, 10).Select(x => new UserControl() { Name = "name" + x });


    My RadTabControl and related template definition is this one :
                <DataTemplate x:Key="ContentAreaTabHeaderTemplate">
                    <TextBlock Text="{Binding DataContext.Name, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerik:RadTabItem}}" FontFamily="Arial" FontSize="13.333" />
            <telerik:RadTabControl x:Name="radtabVariableControlsContainer"                               
                                   ItemTemplate="{StaticResource ContentAreaTabHeaderTemplate}"
                                   ItemDropDownContentTemplate="{StaticResource ContentAreaTabHeaderTemplate}"/>

    It so work find for ItemTemplate to display Tabs Header, but I don't succeed in displaying UserControls names in DropDown.
    The "name" property never appear in dropdown...

    Many thanks for your help !

  2. Petar Mladenov
    Petar Mladenov avatar
    2882 posts

    Posted 13 Dec 2011 Link to this post

    Hi Yann,

     The behavior you have come up is expected. Binding to RelativeSource traverses the Visual Tree to find the right datacontext. But this cannot be applied to elements in the DropDownContent of a DropDownButton because this DropDownContent is actually a Popup and it is located on other VisualTree, different from the TabControl's one. So I highly suggest you to use ViewModels that are not UserControls or other Visual Elements and you won't need to use "FindAncestor" type of binding.

    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
Back to Top