i am a beginner in wpf and trying to understand the solution in the below Url, as i have to create a condition in Event Trigger.
How to give the condition for EventTrigger?
Can anyone please explain the line my:ConditionalEventTrigger.Triggers. I am trying to understand where did the triggers came from. Is it from the attached property, if that is the case i tried creating my own attached properties but was not able to see them.
public static ConditionalEventTriggerCollection GetTriggers(DependencyObject obj) { return (ConditionalEventTriggerCollection)obj.GetValue(OwnProperty); }
public static void SetTriggers2(DependencyObject obj, ConditionalEventTriggerCollection2 value) { obj.SetValue(OwnProperty, value); }
public static readonly DependencyProperty OwnProperty = DependencyProperty.RegisterAttached("Own", typeof(ConditionalEventTriggerCollection2), typeof(TestingCustomTriggers), new PropertyMetadata
{
PropertyChangedCallback = (obj, e) =>
{
// When "Triggers" is set, register handlers for each trigger in the list
var element = (FrameworkElement)obj;
var triggers = (List<TestingCustomTriggers>)e.NewValue;
foreach (var trigger in triggers)
element.AddHandler(trigger.RoutdEvent, new RoutedEventHandler((obj2, e2) =>
trigger.OnRoutedEvent(element)));
}
});
I created my own attached property like above but for some reason, I was not able to see it. I really appreciate your time in looking into this.
thanks