A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

40 lines
1.2 KiB

// -----------------------------------------------------------------------
// <copyright file="TreeViewItem.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Controls
{
public class TreeViewItem : HeaderedItemsControl
{
public static readonly PerspexProperty<bool> IsExpandedProperty =
PerspexProperty.Register<TreeViewItem, bool>("IsExpanded");
TreeView parent;
public bool IsExpanded
{
get { return this.GetValue(IsExpandedProperty); }
set { this.SetValue(IsExpandedProperty, value); }
}
protected override Control CreateItemControlOverride(object item)
{
if (this.parent != null)
{
return this.parent.CreateItemControl(item);
}
else
{
return null;
}
}
protected override void OnAttachedToVisualTree()
{
base.OnAttachedToVisualTree();
this.parent = this.GetVisualAncestor<TreeView>();
}
}
}