Hi.
I am trying to use TabControl to display many userControls.
However I am struggling to achieve how to add the infamous close button.
Being me a novice with silverlight there is many things that I still can't do, so I am asking for your help.
This is my view on control. I had it working if it were binding to a actual ViewModel, but I am adding programatically my tabItem:
How can I change xaml in order to accept a close button and set my content as user control?
Thanks in advance
Ps.
Telerik could think on having a property on radtabcontrol so if it were enabled it would display close button and his feature as default.
I am trying to use TabControl to display many userControls.
However I am struggling to achieve how to add the infamous close button.
Being me a novice with silverlight there is many things that I still can't do, so I am asking for your help.
<
UserControl
x:Class
=
"DoisSoft.TTrack.TabsControl.TabsControlView"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable
=
"d"
>
<
UserControl.Resources
>
<
Style
x:Key
=
"CloseButton"
TargetType
=
"Button"
>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"Button"
>
<
Grid
Background
=
"Transparent"
Width
=
"14"
Height
=
"14"
>
<
VisualStateManager.VisualStateGroups
>
<
VisualStateGroup
x:Name
=
"CommonStates"
>
<
VisualState
x:Name
=
"Normal"
/>
<
VisualState
x:Name
=
"MouseOver"
>
<
Storyboard
>
<
ObjectAnimationUsingKeyFrames
Storyboard.TargetProperty
=
"(UIElement.Visibility)"
Storyboard.TargetName
=
"FocusEllipse"
>
<
DiscreteObjectKeyFrame
KeyTime
=
"0"
>
<
DiscreteObjectKeyFrame.Value
>
<
Visibility
>Visible</
Visibility
>
</
DiscreteObjectKeyFrame.Value
>
</
DiscreteObjectKeyFrame
>
</
ObjectAnimationUsingKeyFrames
>
<
ColorAnimation
Duration
=
"0"
To
=
"#FFDC3030"
Storyboard.TargetProperty
=
"(Shape.Fill).(SolidColorBrush.Color)"
Storyboard.TargetName
=
"FocusEllipse"
/>
<
ColorAnimation
Duration
=
"0"
To
=
"White"
Storyboard.TargetProperty
=
"(Shape.Stroke).(SolidColorBrush.Color)"
Storyboard.TargetName
=
"path"
/>
</
Storyboard
>
</
VisualState
>
<
VisualState
x:Name
=
"Pressed"
>
<
Storyboard
>
<
ObjectAnimationUsingKeyFrames
Storyboard.TargetProperty
=
"(UIElement.Visibility)"
Storyboard.TargetName
=
"FocusEllipse"
>
<
DiscreteObjectKeyFrame
KeyTime
=
"0"
>
<
DiscreteObjectKeyFrame.Value
>
<
Visibility
>Visible</
Visibility
>
</
DiscreteObjectKeyFrame.Value
>
</
DiscreteObjectKeyFrame
>
</
ObjectAnimationUsingKeyFrames
>
<
ColorAnimation
Duration
=
"0"
To
=
"Black"
Storyboard.TargetProperty
=
"(Shape.Fill).(SolidColorBrush.Color)"
Storyboard.TargetName
=
"FocusEllipse"
/>
<
ColorAnimation
Duration
=
"0"
To
=
"White"
Storyboard.TargetProperty
=
"(Shape.Stroke).(SolidColorBrush.Color)"
Storyboard.TargetName
=
"path"
/>
</
Storyboard
>
</
VisualState
>
<
VisualState
x:Name
=
"Disabled"
/>
</
VisualStateGroup
>
<
VisualStateGroup
x:Name
=
"FocusStates"
>
<
VisualState
x:Name
=
"Focused"
/>
<
VisualState
x:Name
=
"Unfocused"
/>
</
VisualStateGroup
>
</
VisualStateManager.VisualStateGroups
>
<
Ellipse
x:Name
=
"FocusEllipse"
Fill
=
"#FFF13535"
Visibility
=
"Collapsed"
/>
<
Path
x:Name
=
"path"
Data
=
"{TemplateBinding Content}"
Stroke
=
"#FF898888"
HorizontalAlignment
=
"Center"
VerticalAlignment
=
"Center"
StrokeThickness
=
"1"
/>
</
Grid
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
<
telerik:ContainerBindingCollection
x:Key
=
"ContainerBindings"
>
<
telerik:ContainerBinding
PropertyName
=
"IsSelected"
Binding
=
"{Binding IsSelected, Mode=TwoWay}"
/>
<
telerik:ContainerBinding
PropertyName
=
"DataContent"
Binding
=
"{Binding DataContent, Mode=TwoWay}"
/>
</
telerik:ContainerBindingCollection
>
<
DataTemplate
x:Key
=
"TabItemTemplate"
telerik:ContainerBinding.ContainerBindings
=
"{StaticResource ContainerBindings}"
>
<
StackPanel
Orientation
=
"Horizontal"
VerticalAlignment
=
"Center"
>
<
TextBlock
Text
=
"{Binding Header}"
/>
<
Button
Command
=
"{Binding RemoveItemCommand}"
Style
=
"{StaticResource CloseButton}"
Margin
=
"10,0,0,0"
Content
=
"M0,0 L6,6 M6, 0 L0,6"
ToolTipService.ToolTip
=
"Remove item"
/>
</
StackPanel
>
</
DataTemplate
>
<
DataTemplate
x:Key
=
"ContentTemplate"
>
<
Grid
Background
=
"White"
Opacity
=
".8"
/>
</
DataTemplate
>
</
UserControl.Resources
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"transparent"
>
<
telerik:RadTabControl
x:Name
=
"tabControl"
AllowDragReorder
=
"True"
IsContentPreserved
=
"True"
ItemsSource
=
"{Binding Tabs}"
>
</
telerik:RadTabControl
>
</
Grid
>
</
UserControl
>
This is my view on control. I had it working if it were binding to a actual ViewModel, but I am adding programatically my tabItem:
newTab =
new
RadTabItem()
{
Header = menu.Designation,
Content =
new
WOF0100View(_eventAggregator, _fleetService),
Tag = menu.Code,
IsSelected =
true
};
How can I change xaml in order to accept a close button and set my content as user control?
Thanks in advance
Ps.
Telerik could think on having a property on radtabcontrol so if it were enabled it would display close button and his feature as default.