Hi,
I am modifying the example shown here: http://www.telerik.com/community/forums/silverlight/tabcontrol/how-to-close-the-tab.aspx to accomplish having a close button on my Tab Header control. Basically I don't want to bind my RadTabControl to a list, but rather to create the RadTabItems programatically. The reason is because the content for each TabItem may differ substantially (we are dynamically generating that content). However, I would sill like to bind the the TabItem to a class. My HeaderTemplate is defined as:
This is what the logic looks like where I create my TabItems. I've cleaned it up to make it easier to see:
Probably is that the ID is not displayed properly in the Tab Header. After some testing I tried binding the TabControl to a list of MyObject instance and that seemed to make the header display correctly. But I really can't do that. Any ideas?
Maybe there is a way to do this without binding the TabItem at all?
-- xavier
I am modifying the example shown here: http://www.telerik.com/community/forums/silverlight/tabcontrol/how-to-close-the-tab.aspx to accomplish having a close button on my Tab Header control. Basically I don't want to bind my RadTabControl to a list, but rather to create the RadTabItems programatically. The reason is because the content for each TabItem may differ substantially (we are dynamically generating that content). However, I would sill like to bind the the TabItem to a class. My HeaderTemplate is defined as:
<
Style
TargetType
=
"my:RadTabItem"
>
<!--Set a template for the header:-->
<
Setter
Property
=
"HeaderTemplate"
>
<
Setter.Value
>
<
DataTemplate
>
<
Grid
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"*"
/>
<
ColumnDefinition
Width
=
"Auto"
/>
</
Grid.ColumnDefinitions
>
<
ContentControl
Content
=
"{Binding Id}"
/>
<
Button
Grid.Column
=
"1"
Margin
=
"3 0 0 0"
Content
=
"x"
Width
=
"12"
Height
=
"12"
HorizontalAlignment
=
"Center"
VerticalAlignment
=
"Center"
telerikrouted:EventHelper.EnableRoutedClick
=
"True"
/>
</
Grid
>
</
DataTemplate
>
</
Setter.Value
>
</
Setter
>
This is what the logic looks like where I create my TabItems. I've cleaned it up to make it easier to see:
var newTab =
new
RadTabItem();
newTab.DataContext = MyObject;
// This object has an Id property
ViewItem viewItem =
new
ViewItem()
newTab.Content = viewItem;
MyTabControl.Items.Add(newTab);
Probably is that the ID is not displayed properly in the Tab Header. After some testing I tried binding the TabControl to a list of MyObject instance and that seemed to make the header display correctly. But I really can't do that. Any ideas?
Maybe there is a way to do this without binding the TabItem at all?
-- xavier