-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSpinnerControl.xaml.cs
51 lines (45 loc) · 1.85 KB
/
SpinnerControl.xaml.cs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Windows;
using System.Windows.Controls;
namespace PhantomUI
{
/// <summary>
/// Interaction logic for SpinnerControl.xaml
/// </summary>
public partial class SpinnerControl : UserControl
{
#region Custom Events
// https://msdn.microsoft.com/en-us/library/ms752288(v=vs.110).aspx
// Create a custom routed event by first registering a RoutedEventID
// This event uses the bubbling routing strategy
public static readonly RoutedEvent StartAnimationEvent = EventManager.RegisterRoutedEvent("StartAnimation", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(SpinnerControl));
public static readonly RoutedEvent StopAnimationEvent = EventManager.RegisterRoutedEvent("StopAnimation" , RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(SpinnerControl));
// Provide CLR accessors for the event
public event RoutedEventHandler StartAnimation
{
add { AddHandler(StartAnimationEvent , value); }
remove { RemoveHandler(StartAnimationEvent, value); }
}
public event RoutedEventHandler StopAnimation
{
add { AddHandler(StopAnimationEvent , value); }
remove { RemoveHandler(StopAnimationEvent, value); }
}
// This method raises the Tap event
public void RaiseStartAnimationEvent()
{
RoutedEventArgs newEventArgs = new RoutedEventArgs(SpinnerControl.StartAnimationEvent);
RaiseEvent(newEventArgs);
}
public void RaiseStopAnimationEvent()
{
RoutedEventArgs newEventArgs = new RoutedEventArgs(SpinnerControl.StopAnimationEvent);
RaiseEvent(newEventArgs);
}
#endregion
public SpinnerControl()
{
InitializeComponent();
}
}
}