我有两个依赖属性,Value
和MinVal
.
我希望“Value”的默认值取决于“MinVal”。
xaml 设置的“MinVal”只有一次。
我怎样才能做到这一点?
这是代码:
public int Value
{
get { return (int)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
// Using a DependencyProperty as the backing store for Value. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(int), typeof(NumericHexUpDown), new UIPropertyMetadata(0, ValueChanged));
private static void ValueChanged(object sender, DependencyPropertyChangedEventArgs e)
{
}
public int MinVal
{
get { return (int)GetValue(MinValProperty); }
set { SetValue(MinValProperty, value); }
}
// Using a DependencyProperty as the backing store for MinVal. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MinValProperty =
DependencyProperty.Register("MinVal", typeof(int), typeof(NumericHexUpDown), new UIPropertyMetadata(0, MinValueChanged));
private static void MinValueChanged(object sender, DependencyPropertyChangedEventArgs e)
{
}