using System.Windows; using System.Windows.Controls; namespace Tango.Hive { public class HexList: ListBox { static HexList() { DefaultStyleKeyProperty.OverrideMetadata(typeof(HexList), new FrameworkPropertyMetadata(typeof(HexList))); } public bool UseHexItemHasContainer { get { return (bool)GetValue(UseHexItemHasContainerProperty); } set { SetValue(UseHexItemHasContainerProperty, value); } } public static readonly DependencyProperty UseHexItemHasContainerProperty = DependencyProperty.Register("UseHexItemHasContainer", typeof(bool), typeof(HexList), new PropertyMetadata(false)); public static readonly DependencyProperty OrientationProperty = HexGrid.OrientationProperty.AddOwner(typeof (HexList)); public static readonly DependencyProperty RowCountProperty = HexGrid.RowCountProperty.AddOwner(typeof (HexList)); public static readonly DependencyProperty ColumnCountProperty = HexGrid.ColumnCountProperty.AddOwner(typeof (HexList)); public Orientation Orientation { get { return (Orientation)GetValue(OrientationProperty); } set { SetValue(OrientationProperty, value); } } public int RowCount { get { return (int)GetValue(RowCountProperty); } set { SetValue(RowCountProperty, value); } } public int ColumnCount { get { return (int)GetValue(ColumnCountProperty); } set { SetValue(ColumnCountProperty, value); } } protected override bool IsItemItsOwnContainerOverride(object item) { return (item is HexItem); } protected override DependencyObject GetContainerForItemOverride() { if (UseHexItemHasContainer) { return new HexItem(); } else { return base.GetContainerForItemOverride(); } } } }