1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| public class TestObject : DependencyObject
{
public TestObject()
{
int vv = 0;
}
#region Test
public object Test
{
get { return (object)GetValue(TestProperty); }
set { SetValue(TestProperty, value); }
}
// Using a DependencyProperty as the backing store for Test. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TestProperty =
DependencyProperty.Register(
"Test",
typeof(object),
typeof(TestObject),
// new PropertyMetadata(null)
new FrameworkPropertyMetadata(null, new PropertyChangedCallback(TestChanged))
// new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender , new PropertyChangedCallback(TestChanged))
);
private static void TestChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
TestObject control = d as TestObject;
}
#endregion
} |
Partager