summaryrefslogtreecommitdiff
path: root/Juick/Classes/DependencyPropertyListener.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/Classes/DependencyPropertyListener.cs')
-rw-r--r--Juick/Classes/DependencyPropertyListener.cs52
1 files changed, 0 insertions, 52 deletions
diff --git a/Juick/Classes/DependencyPropertyListener.cs b/Juick/Classes/DependencyPropertyListener.cs
deleted file mode 100644
index 693c16a..0000000
--- a/Juick/Classes/DependencyPropertyListener.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System;
-using System.Windows;
-using System.Windows.Data;
-
-namespace Juick.Classes
-{
- public class DependencyPropertyListener
- {
- static int index;
-
- readonly DependencyProperty property;
- FrameworkElement target;
- public event EventHandler<BindingChangedEventArgs> Changed;
-
- public DependencyPropertyListener()
- {
- property = DependencyProperty.RegisterAttached(
- "DependencyPropertyListener" + DependencyPropertyListener.index++,
- typeof(object),
- typeof(DependencyPropertyListener),
- new PropertyMetadata(null, new PropertyChangedCallback(HandleValueChanged)));
- }
-
- public void Attach(FrameworkElement element, Binding binding)
- {
- if (element == null)
- {
- throw new ArgumentNullException("element");
- }
- if (target != null)
- {
- throw new InvalidOperationException("Cannot attach an already attached listener");
- }
- target = element;
- target.SetBinding(property, binding);
- }
-
- public void Detach()
- {
- target.ClearValue(property);
- target = null;
- }
-
- void HandleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
- {
- if (Changed != null)
- {
- Changed.Invoke(this, new BindingChangedEventArgs(e));
- }
- }
- }
-}