Option Explicit
Private Sub Form_Load()
Dim sXaml As String
sXaml = "<Page xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' Width='800' Height='500'>" sXaml = sXaml & "<Border><StackPanel x:Name='RecentList'>" sXaml = sXaml & "<TextBlock x:Name='Recent1' TextWrapping='Wrap' Margin='0,0,0,2'><Hyperlink x:Name='txtRecent1' Tag='Recent1' Click='HyperClick' MouseEnter='HyperEnter' MouseLeave='HyperLeave' TextDecorations='' Foreground='#2f719c'>Recent Item 1</Hyperlink></TextBlock>" sXaml = sXaml & "</StackPanel></Border></Page>" Markup.MarkupContext.SetHandler Me Markup.Caption = sXaml AddRecentEntry "Recent Item 2" End Sub
Private Sub AddRecentEntry(ByVal sDB As String)
Dim SP As MarkupStackPanel Dim TB As MarkupTextBlock Dim HL As MarkupHyperlink ' Find the recent database list Set SP = Markup.MarkupUIElement.FindName("RecentList") If Not SP Is Nothing Then
' Create a new Hyperlink Set HL = Markup.MarkupContext.CreateObject("Hyperlink") If Not HL Is Nothing Then HL.Name = "txtRecent2" HL.Tag = "Recent2" HL.AddHandler HL.ClickEvent, "HyperClick" HL.AddHandler HL.MouseEnterEvent, "HyperEnter" HL.AddHandler HL.MouseLeaveEvent, "HyperLeave" HL.TextDecorations = xtpMarkupTextDecorationsNone HL.Foreground = Markup.MarkupContext.CreateSolidBrush(&H9C712F) End If
' Create a new TextBlock Set TB = Markup.MarkupContext.CreateObject("TextBlock") If Not TB Is Nothing Then TB.Name = "txtRecent5" TB.TextWrapping = xtpMarkupTextWrap ' TB.Margin.Bottom = 2 TB.Text = sDB End If TB.Inlines.Add HL SP.Children.Add TB End If
End Sub
Public Sub HyperClick(ByVal Sender As MarkupObject, ByVal Args As MarkupRoutedEventArgs) Debug.Print "Click", Sender.Name, Sender.Tag, Args.Event.Name End Sub
Public Sub HyperEnter(ByVal Sender As MarkupObject, ByVal Args As MarkupRoutedEventArgs) Debug.Print "Enter", Sender.Name, Sender.Tag, Args.Event.Name End Sub
Public Sub HyperLeave(ByVal Sender As MarkupObject, ByVal Args As MarkupRoutedEventArgs) Debug.Print "Leave", Sender.Name, Sender.Tag, Args.Event.Name End Sub
|