问题描述
请教个Trigger修改依赖属性的问题:.cs:publicboolIsMouseUpon{get{return(bool)GetValue(IsMouseUponProperty);}set{SetValue(IsMouseUponProperty,value);}}publicstaticreadonlyDependencyPropertyIsMouseUponProperty=DependencyProperty.Register("IsMouseUpon",typeof(bool),typeof(StateMenuImage),newFrameworkPropertyMetadata(false));.xaml.cs:<Stylex:Key="StateMenuImageFocusStyle"TargetType="{x:Typemenus:StateMenuImage}"><Style.Triggers><TriggerProperty="IsMouseOver"Value="True"><SetterProperty="IsMouseUpon"Value="True"/></Trigger><TriggerProperty="IsMouseOver"Value="False"><SetterProperty="IsMouseUpon"Value="False"/></Trigger>********鼠标移上、移开时,IsMouseUpon的值变了,但并未调用到我属性定义时的SetValue位置,而我想要IsMouseUpon值改变时执行某些东西。我应该怎么修改,或者我应该怎么做?另外,当我修改我的依赖属性为:publicstaticreadonlyDependencyPropertyIsMouseUponProperty=DependencyProperty.Register("IsMouseUpon",typeof(bool),typeof(StateMenuImage),newFrameworkPropertyMetadata(false,newPropertyChangedCallback(OnSourceChanged)),newValidateValueCallback(IsValueChanged));只有第一次鼠标移动上去时,调用了OnSourceChanged、IsValueChanged方法,移开以及后续鼠标移入、移除,并未执行这两个方法。谁能帮我解下惑?