|
///
/// Copyright(C) MixModes Inc. 2010
///
using System;
using System.Windows;
using System.Windows.Interactivity;
using MixModes.Synergy.VisualFramework.Windows;
namespace MixModes.Synergy.VisualFramework.Behaviors
{
public abstract class WindowsManagerBehavior : Behavior<FrameworkElement>
{
/// <summary>
/// Called after the behavior is attached to an AssociatedObject.
/// </summary>
/// <remarks>Override this to hook up functionality to the AssociatedObject.</remarks>
/// <exception cref="InvalidOperationException">WindowsManager does not exist in logical tree</exception>
protected override void OnAttached()
{
base.OnAttached();
FindWindowsManager();
}
/// <summary>
/// Windows manager
/// </summary>
protected WindowsManager WindowsManager
{
get;
private set;
}
/// <summary>
/// Finds the windows manager
/// </summary>
/// <exception cref="InvalidOperationException">WindowsManager does not exist in logical tree</exception>
private void FindWindowsManager()
{
DependencyObject currentElement = AssociatedObject;
while (currentElement != null)
{
currentElement = LogicalTreeHelper.GetParent(currentElement);
if (currentElement is WindowsManager)
{
WindowsManager = currentElement as WindowsManager;
return;
}
}
throw new InvalidOperationException("No WindowsManager found in logical tree");
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Ashish worked for Microsoft for a number of years in Microsoft Visual Studio (Architect edition) and Windows Live division as a developer. Before that he was a developer consultant mainly involved in distributed service development / architecture. His main interests are distributed software architecture, patterns and practices and mobile device development.
Currently Ashish serves as a Technical Lead at RIM leading next generation BlackBerry media experience and also runs his own company MixModes Inc. specializing in .NET / WPF / Silverlight technologies. You can visit MixModes at http://mixmodes.com or follow it on Twitter @MixModes
In his free time he is an avid painter, hockey player and enjoys travelling. His blog is at: http://ashishkaila.serveblog.net