Canvas.SetTop : Canvas « Windows Presentation Foundation « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Windows Presentation Foundation » CanvasScreenshots 
Canvas.SetTop
Canvas.SetTop
  
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Canvas_Positioning_Properties.Window1"
    Title="Canvas Positioning Properties">
  <StackPanel>
    <Canvas Name="canvas1" Height="300">
        <TextBlock Name="text1" FontWeight="Bold" Canvas.Left="0" Canvas.Right="0" Canvas.Top="0" Canvas.Bottom="0">A TextBlock.</TextBlock>
  </Canvas>
    <ListBox Grid.Column="5" Grid.Row="1" VerticalAlignment="Top" Width="60" Margin="10,0,0,0" SelectionChanged="ChangeTop">
      <ListBoxItem>Auto</ListBoxItem>      
      <ListBoxItem>10</ListBoxItem>
      <ListBoxItem>20</ListBoxItem>
      <ListBoxItem>30</ListBoxItem>
      <ListBoxItem>40</ListBoxItem>
      <ListBoxItem>50</ListBoxItem>
      <ListBoxItem>60</ListBoxItem>
      <ListBoxItem>70</ListBoxItem>
      <ListBoxItem>80</ListBoxItem>
      <ListBoxItem>90</ListBoxItem>
      <ListBoxItem>100</ListBoxItem>  
    </ListBox>

  </StackPanel>        
</Window>
//File:Window.xaml.cs

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Data;

namespace Canvas_Positioning_Properties
{

  public partial class Window1 : Window
  {
    public void ChangeTop(object sender, SelectionChangedEventArgs args)
    {
            ListBoxItem li3 = ((sender as ListBox).SelectedItem as ListBoxItem);
            LengthConverter myLengthConverter = new LengthConverter();
      Double db3 = (Double)myLengthConverter.ConvertFromString(li3.Content.ToString());
      Canvas.SetTop(text1, db3);
      Console.WriteLine(myLengthConverter.ConvertToString(Canvas.GetTop(text1)));
    }


  }
}

   
    
  
Related examples in the same category
1.Nested CanvasNested Canvas
2.Positioning on a CanvasPositioning on a Canvas
3.Canvas without ViewboxCanvas without Viewbox
4.Animation target Canvas Left, TopAnimation target Canvas Left, Top
5.Pixel Not SnappedPixel Not Snapped
6.Rotate ShapeRotate Shape
7.Canvas dependantCanvas dependant
8.Simple Canvas LayoutSimple Canvas Layout
9.Canvas.SetBottomCanvas.SetBottom
10.Canvas.SetRightCanvas.SetRight
11.Canvas PreviewMouseDown action and MouseDown actionCanvas PreviewMouseDown action and MouseDown action
12.Create a Scrollable Canvas ControlCreate a Scrollable Canvas Control
13.Create a Zoomable Canvas ControlCreate a Zoomable Canvas Control
14.Set control position for CanvasSet control position for Canvas
15.Canvas Positioning Properties SampleCanvas Positioning Properties Sample
16.Get position on a Canvas with Canvas.GetLeftGet position on a Canvas with Canvas.GetLeft
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.