Navigate Frame to a URL : Frame « Windows Presentation Foundation « VB.Net Tutorial






<Window x:Class="TreeViewDataBinding.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="TreeViewDataBinding"
    xmlns:EngNews="clr-namespace:TreeViewDataBinding">

  <Window.Resources>
    <ObjectDataProvider x:Key="EasternHemisphereDataSource" ObjectType="{x:Type EngNews:WebSiteGroupA}"/>
    <ObjectDataProvider x:Key="WesternHemisphereDataSource" ObjectType="{x:Type EngNews:WebSiteGroupB}"/>
    <DataTemplate x:Key="NewspaperTVItem">
      <DockPanel>
        <Image Source="c:\image.jpg"/>
        <TextBlock VerticalAlignment="center" Text ="{Binding Path=Name}"/>
      </DockPanel>
    </DataTemplate>
    <DataTemplate x:Key="WesternHemisphereHeaderTemplate">
      <DockPanel>
        <Ellipse Width="7" Height="7"  Fill="Blue" DockPanel.Dock="Left"/>
        <TextBlock Margin="2,0,0,0" VerticalAlignment="Center" DockPanel.Dock="Right">
          test
        </TextBlock>
      </DockPanel>
    </DataTemplate>
    <DataTemplate x:Key="EasternHemisphereHeaderTemplate">
      <DockPanel>
        <Ellipse Width="7" Height="7"  Fill="Blue" DockPanel.Dock="Left"/>
        <TextBlock DockPanel.Dock="Right">Eastern Hemisphere</TextBlock>
      </DockPanel>
    </DataTemplate>
  </Window.Resources>
  <StackPanel>
      <TreeView Name="WebSiteEntrys" SelectedItemChanged="SelectedNewspaperChanged">
        <TreeViewItem HeaderTemplate="{StaticResource WesternHemisphereHeaderTemplate}" 
                      ItemsSource="{Binding Source={StaticResource WesternHemisphereDataSource}}"
                      ItemTemplate="{StaticResource NewspaperTVItem}"/>
        <TreeViewItem HeaderTemplate="{StaticResource EasternHemisphereHeaderTemplate}"
                      ItemsSource="{Binding Source={StaticResource EasternHemisphereDataSource}}"
                      ItemTemplate="{StaticResource NewspaperTVItem}"/>
      </TreeView>
      <Frame Name = "NewspaperFrame" Content="this is a test."/>
  </StackPanel>
</Window>
//File:Window.xaml.vb
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Media
Imports System.Windows.Shapes
Imports System.Collections.ObjectModel

Namespace TreeViewDataBinding
  Public Partial Class Window1
    Inherits Window
    Public Sub New()
      InitializeComponent()
    End Sub
    Private Sub SelectedNewspaperChanged(sender As Object, e As RoutedPropertyChangedEventArgs(Of [Object]))
      Dim engnews As WebSiteEntry = TryCast(WebSiteEntrys.SelectedItem, WebSiteEntry)
      If engnews IsNot Nothing Then
        NewspaperFrame.Navigate(New System.Uri(engnews.Website))
      End If
    End Sub
  End Class
  Public Class WebSiteEntry
    Private _name As String
    Private _website As String

    Public Property Website() As String
      Get
        Return _website
      End Get
      Set
        _website = value
      End Set
    End Property

    Public Property Name() As String
      Get
        Return _name
      End Get
      Set
        _name = value
      End Set
    End Property

    Public Sub New(name__1 As String, website__2 As String)
      Name = name__1
      Website = website__2
    End Sub
  End Class
  Public Class WebSiteGroupA
    Inherits ObservableCollection(Of WebSiteEntry)
    Public Sub New()
      Add(New WebSiteEntry("A", "http://www.A.com"))
      Add(New WebSiteEntry("B", "http://www.B.com"))
      Add(New WebSiteEntry("C", "http://www.C.com"))
    End Sub
  End Class

  Public Class WebSiteGroupB
    Inherits ObservableCollection(Of WebSiteEntry)
    Public Sub New()
      Add(New WebSiteEntry("D", "http://www.D.com/"))
      Add(New WebSiteEntry("E", "http://www.E.net/"))
      Add(New WebSiteEntry("F", "http://www.F.com"))
    End Sub
  End Class
End Namespace
WPF Navigate Framw To A U R L








16.48.Frame
16.48.1.System.Windows.Controls.Frame.CanGoBack, GoBack, CanGoForward, GoForwardSystem.Windows.Controls.Frame.CanGoBack, GoBack, CanGoForward, GoForward
16.48.2.Use a Frame control to navigate to Web pages and a Extensible Application Markup Language (XAML) page.Use a Frame control to navigate to Web pages and a Extensible Application Markup Language (XAML) page.
16.48.3.Put a Frame tag onto a Window to host a pagePut a Frame tag onto a Window to host a page
16.48.4.Navigate Frame to a xaml documentNavigate Frame to a xaml document
16.48.5.Navigate Frame to a URLNavigate Frame to a URL