Recent Posts
C++ | 19 sec ago
None | 28 sec ago
C | 31 sec ago
None | 45 sec ago
None | 45 sec ago
Diff | 1 min ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Anonymous on the 9th of Feb 2010 07:27:30 PM Download | Raw | Embed | Report
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Data;
  4.  
  5. namespace dp_test
  6. {
  7.         class A : DependencyObject
  8.         {
  9.                 public int Val
  10.                 {
  11.                         get { return (int)GetValue(ValProperty); }
  12.                         set { SetValue(ValProperty, value); }
  13.                 }
  14.  
  15.                 public static readonly DependencyProperty ValProperty =
  16.                         DependencyProperty.Register("Val", typeof(int), typeof(A), null);
  17.  
  18.  
  19.         }
  20.  
  21.         class B : DependencyObject
  22.         {
  23.                 public int Val
  24.                 {
  25.                         get { return (int)GetValue(ValProperty); }
  26.                         set { SetValue(ValProperty, value); }
  27.                 }
  28.  
  29.                 public static readonly DependencyProperty ValProperty =
  30.                         DependencyProperty.Register("Val", typeof(int), typeof(B), null);
  31.         }
  32.  
  33.         class Program
  34.         {
  35.                 static void Main(string[] args)
  36.                 {
  37.                         A aaa = new A();
  38.                         B bbb = new B();
  39.  
  40.                         Binding binding = new Binding("Val");
  41.                         binding.Source = bbb;
  42.  
  43.                         BindingOperations.SetBinding(aaa, A.ValProperty, binding);
  44.  
  45.                         bbb.Val = 7;
  46.  
  47.                         Console.WriteLine("A = " + aaa.Val + ", B = " + bbb.Val);
  48.                 }
  49.         }
  50. }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: