using System;
using System.Windows.Interactivity;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace WpfApplication1
{
    public abstract class LoadBehavior<TFrameworkElement> : Behavior<TFrameworkElement> where TFrameworkElement : FrameworkElement
    {
        protected override void OnAttached()
        {
            base.OnAttached();
            this.AssociatedObject.Loaded += OnAssociatedObjectLoaded;
        }

        protected override void OnDetaching()
        {
            base.OnDetaching();
            this.AssociatedObject.Loaded -= OnAssociatedObjectLoaded;
        }

        private void OnAssociatedObjectLoaded(object sender, RoutedEventArgs e)
        {
            this.OnAssociatedObjectLoaded();   
        }

        protected virtual void OnAssociatedObjectLoaded()
        {
        }
    }
}
