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

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Windows Presentation Foundation » Frame 
16.48.5.Navigate Frame to a URL
<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
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.