Untitled
By: a guest | Feb 9th, 2010 | Syntax:
C# | Size: 0.98 KB | Hits: 28 | Expires: Never
using System;
using System.Windows;
using System.Windows.Data;
namespace dp_test
{
class A : DependencyObject
{
public int Val
{
get { return (int)GetValue(ValProperty); }
set { SetValue(ValProperty, value); }
}
public static readonly DependencyProperty ValProperty =
DependencyProperty.
Register("Val",
typeof(int),
typeof(A
),
null);
}
class B : DependencyObject
{
public int Val
{
get { return (int)GetValue(ValProperty); }
set { SetValue(ValProperty, value); }
}
public static readonly DependencyProperty ValProperty =
DependencyProperty.
Register("Val",
typeof(int),
typeof(B
),
null);
}
class Program
{
static void Main(string[] args)
{
Binding binding
= new Binding
("Val");
binding.Source = bbb;
BindingOperations.SetBinding(aaa, A.ValProperty, binding);
bbb.Val = 7;
Console.WriteLine("A = " + aaa.Val + ", B = " + bbb.Val);
}
}
}