[Html]
<Window x: Class = "TestOfAttachPropertyOfSlider. MainWindow"
Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
Title = "MainWindow" Height = "350" Width = "525">
<Canvas>
<Slider x: Name = "sliderX"
Canvas. Top = "10"
Canvas. Left = "10"
Width = "260"
Minimum = "50"
Maximum = "200"/>
<Slider x: Name = "sliderY"
Canvas. Top = "40"
Canvas. Left = "10"
Width = "260"
Minimum = "50"
Maximum = "200"/>
<Rectangle x: Name = "rect" Fill = "Blue"
Width = "30" Height = "30"
Canvas. Left = "{Binding ElementName = sliderX, Path = Value }"
Canvas. Top = "{Binding ElementName = sliderY, Path = Value}"/>
</Canvas>
</Window>
<Window x: Class = "TestOfAttachPropertyOfSlider. MainWindow"
Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
Title = "MainWindow" Height = "350" Width = "525">
<Canvas>
<Slider x: Name = "sliderX"
Canvas. Top = "10"
Canvas. Left = "10"
Width = "260"
Minimum = "50"
Maximum = "200"/>
<Slider x: Name = "sliderY"
Canvas. Top = "40"
Canvas. Left = "10"
Width = "260"
Minimum = "50"
Maximum = "200"/>
<Rectangle x: Name = "rect" Fill = "Blue"
Width = "30" Height = "30"
Canvas. Left = "{Binding ElementName = sliderX, Path = Value }"
Canvas. Top = "{Binding ElementName = sliderY, Path = Value}"/>
</Canvas>
</Window>
Latency>
Equivalent C # code
[Csharp]
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Using System. Windows;
Using System. Windows. Controls;
Using System. Windows. Data;
Using System. Windows. Documents;
Using System. Windows. Input;
Using System. Windows. Media;
Using System. Windows. Media. Imaging;
Using System. Windows. Navigation;
Using System. Windows. Shapes;
Namespace TestOfAttachPropertyOfSlider
{
/// <Summary>
/// Interaction logic for MainWindow. xaml
/// </Summary>
Public partial class MainWindow: Window
{
Public MainWindow ()
{
InitializeComponent ();
This. rect. SetBinding (Canvas. LeftProperty, new Binding ("Value ")
{
Source = sliderX
});
This. rect. SetBinding (Canvas. RightProperty, new Binding ("Value ")
{
Source = sliderY
});
}
}
}
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Using System. Windows;
Using System. Windows. Controls;
Using System. Windows. Data;
Using System. Windows. Documents;
Using System. Windows. Input;
Using System. Windows. Media;
Using System. Windows. Media. Imaging;
Using System. Windows. Navigation;
Using System. Windows. Shapes;
Namespace TestOfAttachPropertyOfSlider
{
/// <Summary>
/// Interaction logic for MainWindow. xaml
/// </Summary>
Public partial class MainWindow: Window
{
Public MainWindow ()
{
InitializeComponent ();
This. rect. SetBinding (Canvas. LeftProperty, new Binding ("Value ")
{
Source = sliderX
});
This. rect. SetBinding (Canvas. RightProperty, new Binding ("Value ")
{
Source = sliderY
});
}
}
}