Created
May 3, 2017 08:49
-
-
Save atzimler/e7f92f909d74fe9de933bf3c90101858 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MultiplyByTwo : DependencyObject | |
| { | |
| private static readonly DependencyPropertyKey ResultPropertyKey = | |
| DependencyProperty.RegisterReadOnly(nameof(Result), typeof(int), typeof(MultiplyByTwo), | |
| new PropertyMetadata(0)); | |
| public static readonly DependencyProperty NumberProperty = | |
| DependencyProperty.Register(nameof(Number), typeof(int), typeof(MultiplyByTwo), | |
| new PropertyMetadata(0, CalculateResult)); | |
| public static readonly DependencyProperty ResultProperty = ResultPropertyKey.DependencyProperty; | |
| public int Number | |
| { | |
| get { return (int)GetValue(NumberProperty); } | |
| set { SetValue(NumberProperty, value); } | |
| } | |
| public int Result | |
| { | |
| get { return (int)GetValue(ResultProperty); } | |
| } | |
| private static void CalculateResult(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
| { | |
| d.SetValue(ResultPropertyKey, (int)e.NewValue * 2); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment