Dependency Prop inside a behavior is static. So its event fires into a static event handler.
But the dependencyObject in the param is the hehavior instance and can call instance method.
public static readonly DependencyProperty TradingLevelProperty = DependencyProperty.Register(
"TradingLevel", typeof(TradingLevelTypes), typeof(NumericTextBoxCustomParamBehavior), new PropertyMetadata(TradingLevelTypes.Low, TradingLevelrPropertyChanged));
public TradingLevelTypes TradingLevel
{
get { return (TradingLevelTypes)GetValue(TradingLevelProperty); }
set { SetValue(TradingLevelProperty, value); }
}
private static void TradingLevelrPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
{
var behaviorInstance = dependencyObject as NumericTextBoxCustomParamBehavior;
if (behaviorInstance != null)
{
behaviorInstance.EnsureNonNullableDataVisibility();
}
}
void EnsureNonNullableDataVisibility()
{
var scrollContentPresenter = AssociatedObject.FindChild("PART_ScrollContentPresenter");
if (scrollContentPresenter != null)
{
scrollContentPresenter.Visibility=TradingLevel== TradingLevelTypes.ServerDefault? Visibility.Hidden: Visibility.Visible;
}
}
Monday, November 7, 2016
Setup Behavior event of its dependency property and connect to the instance not static
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment