Navigate Frame to a URL

image_pdfimage_print


   
  


<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;
            if( engnews != 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"));
        }
    }
}

   
    
     


LineGeometry

image_pdfimage_print


   
    

<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
          <Path Stroke="Black" StrokeThickness="1">
            <Path.Data>
              <LineGeometry StartPoint="10,10" EndPoint="50,30" />
            </Path.Data>
          </Path>

</Window>

   
    
    
    
     


EllipseGeometry

image_pdfimage_print
   
    

<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
          <Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
            <Path.Data>
              <EllipseGeometry Center="40,70" RadiusX="30" RadiusY="30" />
            </Path.Data>
          </Path>

</Window>

   
    
    
    
     


RectangleGeometry

image_pdfimage_print


   
    

<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
          <Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
            <Path.Data>
              <RectangleGeometry Rect="30,55 100 30" />
            </Path.Data>
          </Path>

</Window>

   
    
    
    
     


Animate GeometryDrawing Examples

image_pdfimage_print


   
    

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="Microsoft.Samples.Graphics.AnimateGeometryDrawingExample" 
  Title="Using a DrawingBrush">

  <DockPanel Name="myAnimatedDrawing" Height="400" Width="400">
          <DockPanel.Background>
            <DrawingBrush  TileMode="FlipXY" Viewport="0,0,100,100" ViewportUnits="Absolute" 
              Viewbox="0,0,1,1" ViewboxUnits="Absolute">
              <DrawingBrush.Drawing>  
                <GeometryDrawing >
                  <GeometryDrawing.Pen>
                    <Pen Brush="Orange" Thickness="0.1" />
                  </GeometryDrawing.Pen>
                  <GeometryDrawing.Geometry>                     
                    <EllipseGeometry RadiusX="0.45" RadiusY="0.2" Center="0.5,0.5" />
                  </GeometryDrawing.Geometry>
                </GeometryDrawing>
              </DrawingBrush.Drawing>
            </DrawingBrush>
          </DockPanel.Background>
  </DockPanel>

  <Page.Triggers>
    <EventTrigger RoutedEvent="Page.Loaded">
      <BeginStoryboard>
        <Storyboard>
          <DoubleAnimation 
            Storyboard.TargetName="myAnimatedDrawing" 
            Storyboard.TargetProperty="(DockPanel.Background).(DrawingBrush.Drawing).(GeometryDrawing.Geometry).(EllipseGeometry.RadiusX)"
            From="0.01" To="0.5" Duration="0:0:10" AutoReverse="True" RepeatBehavior="Forever" />         
        </Storyboard>
      </BeginStoryboard>
    </EventTrigger>
  </Page.Triggers>
</Page>

   
    
    
    
     


CombinedGeometry for Path.Data and DrawingBrush for Path.Fill

image_pdfimage_print


   
    

<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
        <Path Stretch="Uniform" Margin="15,0,0,0">
          <Path.Data>
            <CombinedGeometry GeometryCombineMode="Union">
              <CombinedGeometry.Geometry1>
                <RectangleGeometry Rect="50,70 100 100" />
              </CombinedGeometry.Geometry1>
              <CombinedGeometry.Geometry2>
                <EllipseGeometry Center="100,70" RadiusX="35" RadiusY="40"/>
              </CombinedGeometry.Geometry2>
            </CombinedGeometry>
          </Path.Data>
          <Path.Fill>
            <DrawingBrush>
              <DrawingBrush.Drawing>
                <ImageDrawing ImageSource="c:image.JPG">
                  <ImageDrawing.Rect>
                    <Rect X="100" Y="100" Width="50" Height="50" />
                  </ImageDrawing.Rect>
                </ImageDrawing>
              </DrawingBrush.Drawing>
            </DrawingBrush>
          </Path.Fill>
        </Path>
</Window>

   
    
    
    
     


Combines two geometries using the XOR combine mode

image_pdfimage_print


   
    
<Window  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="SDKSample.SampleViewer"
    Title="Opacity Masking Examples" >

   <Canvas> 
        <Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
          <Path.Data>
            <CombinedGeometry GeometryCombineMode="Xor">
              <CombinedGeometry.Geometry1>
                <EllipseGeometry RadiusX="50" RadiusY="50" Center="75,75" />
              </CombinedGeometry.Geometry1>
              <CombinedGeometry.Geometry2>
                <EllipseGeometry RadiusX="50" RadiusY="50" Center="125,75" />
              </CombinedGeometry.Geometry2>
            </CombinedGeometry>
          </Path.Data>
        </Path>
    </Canvas> 


</Window>