Origin in center. Y increases going down


   
    
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid.Resources>
        <Style TargetType="{x:Type Canvas}">
            <Setter Property="Width" Value="100" />
            <Setter Property="Height" Value="100" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>

        <Style TargetType="{x:Type Path}">
            <Setter Property="Fill" Value="Red" />
            <Setter Property="Data">
                <Setter.Value>
                    <EllipseGeometry Center="0 0" RadiusX="5" RadiusY="5" />
                </Setter.Value>
            </Setter>
        </Style>
    </Grid.Resources>


    <Canvas Grid.Column="2">
        <Canvas.RenderTransform>
            <TransformGroup>
                <ScaleTransform ScaleY="1" />
                <TranslateTransform X="50" Y="50" />
            </TransformGroup>
        </Canvas.RenderTransform>

        <Line X1="0" Y1="0" X2="50" Y2="50" Stroke="Black" />
        <Polyline Points="-50 -50 50 -50 50 50 -50 50 -50 -50" Stroke="Blue" />
        <Path />
    </Canvas>

</Grid>

   
    
    
    
     


Determine the layout position of an element using the LayoutInformation


   
  


<Window  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="layout_information.Window1"
    Title="LayoutInformation Sample">
    <Border Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top">
      <Grid Name="myGrid" Height="150">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="250"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition />
          <RowDefinition />
          <RowDefinition />
        </Grid.RowDefinitions>
        <TextBlock Name="txt1" Margin="5" Grid.Column="0" Grid.Row="0">Hello World!</TextBlock>
        <Button Click="ShowLayoutSlot" Width="125" Height="25" Grid.Column="0" Grid.Row="1">Show Bounding Box</Button>

      </Grid>
  </Border>  
</Window>

//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;

namespace layout_information
{
  public partial class Window1 : Window
  {
        public void ShowLayoutSlot(object sender, System.Windows.RoutedEventArgs e)
        {
            RectangleGeometry myRectangleGeometry = new RectangleGeometry();
            myRectangleGeometry.Rect = LayoutInformation.GetLayoutSlot(txt1);
            
            GeometryDrawing myGeometryDrawing = new GeometryDrawing();
            Path myPath = new Path();
            myPath.Data = myRectangleGeometry;

            myPath.Stroke = Brushes.LightGoldenrodYellow;
            myPath.StrokeThickness = 1;
            Grid.SetColumn(myPath, 0);
            Grid.SetRow(myPath, 0);
            myGrid.Children.Add(myPath);
            
            Console.WriteLine(LayoutInformation.GetLayoutSlot(txt1).ToString());
        }
  }
}

   
    
     


Embedded Font


   
     
<Window x:Class="ClassicControls.EmbeddedFont"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ClassicControls" Height="300" Width="300"
    >
    <Grid>
      <Label Name="tst" FontSize="20" FontFamily="./#Bayern"
             >This is an embedded font</Label>
    </Grid>
</Window>

   
    
    
    
    
     


Binding Label to TextBox


   
    

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      HorizontalAlignment="Center" VerticalAlignment="Center">

    <StackPanel Orientation="Horizontal">
    
        <Label Target="{Binding ElementName=nameText}">_Name:</Label>
        <TextBox x:Name="nameText" Width="70" />
    
    </StackPanel>

</Page>

   
    
    
    
     


Set AccessText for Label


   
   

<StackPanel
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="LabelSimple.Pane1">

    <DockPanel Margin="30,10,3,3" Grid.Column="0" Grid.Row="4">
        <TextBox Name="textBox1" Width="50" Height="20"/>
        <Label Width="200" HorizontalAlignment="Left"
             Target="{Binding ElementName=textBox1}">
            <AccessText TextWrapping="WrapWithOverflow">
                _Another long piece of text that requires text wrapping
          goes here.
            </AccessText>
        </Label>
    </DockPanel>


</StackPanel>