This question is locked. New answers and comments are not allowed.
i using telerik silverlight trial version.
I
using a tab
control.
By making each
tab is added to
dedicated memory.
Each tab bind to
a View model .
How can I close
a tab with
slot to release it?
please help me for after closeing a tabitem, dispose view model.
my code:
Private Sub AddTab(ByVal obj As Object, ByVal Header As String)
CType(Me.DataContext, MainViewModel).MyHeader = Header
CType(Me.DataContext, MainViewModel).AddItem(Nothing)
Dim r As New RadTabItem
r = tabControl.Item(tabControl.Items.Count - 1)
r.Content = obj
tabControl.SelectedIndex = tabControl.Items.Count - 1
End Sub
.
.
.
Private Sub Archive_ItemDoubleClick(ByVal sender As Object, ByVal e As Telerik.Windows.RadRoutedEventArgs) Handles Archive.ItemDoubleClick
Select Case CType(e.Source, RadTreeViewItem).Tag
Case "UserProfile"
AddTab(New vUserProfile, "My Profile")
Case "ChangePassword"
AddTab(New vUserChangePassword, "Change Password")
Case Else
End Select
End Sub
.
.
.
<
UserControl.Resources
>
<
local:ValueInverter
x:Key
=
"Inverter"
/>
<
local:vmMainPage
x:Key
=
"vmMainPage"
/>
<
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: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
=
"Close"
/>
</
StackPanel
>
</
DataTemplate
>
<
DataTemplate
x:Key
=
"ContentTemplate"
>
<
Grid
/>
</
DataTemplate
>
</
UserControl.Resources
>
<
telerik:RadTabControl
Margin
=
"3"
x:Name
=
"tabControl"
ItemsSource
=
"{Binding Tabs}"
HorizontalContentAlignment
=
"Stretch"
VerticalContentAlignment
=
"Stretch"
ItemTemplate
=
"{StaticResource TabItemTemplate}"
FontFamily
=
"Tahoma"
>
</
telerik:RadTabControl
>