MainPage.xaml
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
Menu.xaml
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
Menu.xaml.vb
----------------------------------------------------------------------------------------------------
_
Partial Public Class Menu
Inherits UserControl
Public Property Items() As MenuItemCollection
Get
Return TryCast(Me.GetValue(ItemsProperty), MenuItemCollection)
End Get
Set(ByVal value As MenuItemCollection)
Me.SetValue(ItemsProperty, value)
End Set
End Property
Public Sub New()
InitializeComponent()
End Sub
Public Shared ItemsProperty As DependencyProperty = DependencyProperty.Register("Items", GetType(MenuItemCollection), GetType(Menu), Nothing)
Private Sub Menu_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
If Me.Items Is Nothing Then
Me.Items = New MenuItemCollection()
End If
For Each i As MenuItem In Me.Items
Me.sp.Children.Add(i)
Next
End Sub
End Class
----------------------------------------------------------------------------------------------------
MenuItemCollection.vb
----------------------------------------------------------------------------------------------------
Public Class MenuItemCollection
Inherits System.Collections.ObjectModel.ObservableCollection(Of MenuItem)
End Class
----------------------------------------------------------------------------------------------------
MenuItem.xaml
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
MenuItem.xaml.vb
----------------------------------------------------------------------------------------------------
Partial Public Class MenuItem
Inherits UserControl
Public Property Text() As String
Get
Return Me.myButton.Content.ToString()
End Get
Set(ByVal value As String)
Me.myButton.Content = value
End Set
End Property
Public Sub New()
InitializeComponent()
End Sub
End Class
----------------------------------------------------------------------------------------------------
|