Loading files
namespace IDE.Core.Utilities
{
using System.Windows;
/// <summary>
/// Implements an XAML proxy which can be used to bind items (TreeViewItem, ListViewItem etc)
/// with a viewmodel that manages the collecrions.
///
/// Source: http://www.thomaslevesque.com/2011/03/21/wpf-how-to-bind-to-data-when-the-datacontext-is-not-inherited/
/// Issue: http://stackoverflow.com/questions/9994241/mvvm-binding-command-to-contextmenu-item
/// </summary>
public class BindingProxy : Freezable
{
public static readonly DependencyProperty DataProperty =
DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));
/// <summary>
/// Gets the data object this class is forwarding to everyone
/// who has a reference to this object.
/// </summary>
public object Data
{
get { return GetValue(DataProperty); }
set { SetValue(DataProperty, value); }
}
/// <summary>
/// Overrides of Freezable
/// </summary>
/// <returns></returns>
protected override Freezable CreateInstanceCore()
{
return new BindingProxy();
}
}
}
366e28f22This file is pinned to the selected release. Download the original to open it in your design tool.