Hello,
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 (http://www.telerik.com/community/forums/wpf/tabcontrol/radtabitem-headertemplate-not-responding-to-binding-to-usercontrol-object-properties.aspx), I succeded in displaying Tab Header with UserControl "Name" property.
To do this, I use a RelativeSource :
I have used your TabControl-Q1.zip sample project (from post above) where I have modified MainWindow.xaml.cs file to create a list of UserControls :
My RadTabControl and related template definition is this one :
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 !
Yann
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 (http://www.telerik.com/community/forums/wpf/tabcontrol/radtabitem-headertemplate-not-responding-to-binding-to-usercontrol-object-properties.aspx), I succeded in displaying Tab Header with UserControl "Name" property.
To do this, I use a RelativeSource :
Text
="{Binding DataContext.Name, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerik:RadTabItem}}"
I have used your TabControl-Q1.zip sample project (from post above) where I have modified MainWindow.xaml.cs file to create a list of UserControls :
this
.radtabVariableControlsContainer.ItemsSource =
Enumerable.Range(0, 10).Select(x => new UserControl() { Name = "name" + x });
My RadTabControl and related template definition is this one :
<
Grid
>
<
Grid.Resources
>
<
DataTemplate
x:Key
=
"ContentAreaTabHeaderTemplate"
>
<
TextBlock
Text
=
"{Binding DataContext.Name, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerik:RadTabItem}}"
FontFamily
=
"Arial"
FontSize
=
"13.333"
/>
</
DataTemplate
>
</
Grid.Resources
>
<
telerik:RadTabControl
x:Name
=
"radtabVariableControlsContainer"
BorderBrush
=
"{x:Null}"
SelectedItemRemoveBehaviour
=
"SelectPrevious"
ItemTemplate
=
"{StaticResource ContentAreaTabHeaderTemplate}"
DropDownDisplayMode
=
"Visible"
ItemDropDownContentTemplate
=
"{StaticResource ContentAreaTabHeaderTemplate}"
/>
</
Grid
>
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 !
Yann