Navigate Frame to a URL : Frame « Windows Presentation Foundation « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » Windows Presentation Foundation » Frame 
24.64.7.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.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Collections.ObjectModel;

namespace TreeViewDataBinding
{
    public partial class Window1 : Window{
        public Window1(){
            InitializeComponent();
        }
        private void SelectedNewspaperChanged(object sender,RoutedPropertyChangedEventArgs<Object> e){
            WebSiteEntry engnews = WebSiteEntrys.SelectedItem as WebSiteEntry;
            ifengnews != null NewspaperFrame.Navigate(new System.Uri(engnews.Website));
        }
    }
    public class WebSiteEntry{
        private string _name;
        private string _website;

        public string Website
        {
            get return _website; }
            set _website = value; }
        }

        public string Name
        {
            get return _name; }
            set _name = value; }
        }

        public WebSiteEntry(string name, string website)
        {
            Name = name;
            Website = website;
        }
    }
    public class WebSiteGroupA : ObservableCollection<WebSiteEntry>
    {
        public WebSiteGroupA()
        {
            Add(new WebSiteEntry("A","http://www.A.com"));
            Add(new WebSiteEntry("B","http://www.B.com"));
            Add(new WebSiteEntry("C","http://www.C.com"));
        }
    }

    public class WebSiteGroupB : ObservableCollection<WebSiteEntry>
    {
        public WebSiteGroupB()
        {
            Add(new WebSiteEntry("D","http://www.D.com/"));
            Add(new WebSiteEntry("E","http://www.E.net/"));
            Add(new WebSiteEntry("F","http://www.F.com"));
        }
    }
}
WPF Navigate Framw To A U R L
24.64.Frame
24.64.1.Use Frame to Load another Xaml fileUse Frame to Load another Xaml file
24.64.2.Frame Navigation Demo WindowFrame Navigation Demo Window
24.64.3.Xaml frame on a TabXaml frame on a Tab
24.64.4.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.
24.64.5.Put a Frame tag onto a Window to host a pagePut a Frame tag onto a Window to host a page
24.64.6.Navigate Frame to a xaml documentNavigate Frame to a xaml document
24.64.7.Navigate Frame to a URLNavigate Frame to a URL
24.64.8.Get the Resize Frame Vertical Border Width
24.64.9.Get the Resize Frame Horizontal Border Height
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.