add basic files

This commit is contained in:
NaBian committed 2019-04-29 23:42:10 +08:00
1 parent 76248707c6
commit 956e7e3247
20 files changed
+270 -15

No files matched your search

@@ -0,0 +1,16 @@
using System.Windows;
namespace HandyControl.Controls
{
public class HeaderedSimpleItemsControl : SimpleItemsControl
{
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(
"Header", typeof(object), typeof(HeaderedSimpleItemsControl), new PropertyMetadata(default(object)));
public object Header
{
get => GetValue(HeaderProperty);
set => SetValue(HeaderProperty, value);
}
}
}
@@ -5,6 +5,7 @@ using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using HandyControl.Data;
namespace HandyControl.Controls
{
@@ -33,7 +34,14 @@ namespace HandyControl.Controls
public SimpleItemsControl()
{
var items = new ObservableCollection<object>();
items.CollectionChanged += OnItemsChanged;
items.CollectionChanged += (s, e) =>
{
if (e.NewItems != null && e.NewItems.Count > 0)
{
SetValue(HasItemsPropertyKey, true);
}
OnItemsChanged(s, e);
};
Items = items;
}
@@ -118,6 +126,14 @@ namespace HandyControl.Controls
protected virtual void OnItemContainerStyleChanged(DependencyPropertyChangedEventArgs e) => Refresh();
internal static readonly DependencyPropertyKey HasItemsPropertyKey =
DependencyProperty.RegisterReadOnly(nameof(HasItems), typeof(bool), typeof(SimpleItemsControl),
new PropertyMetadata(ValueBoxes.FalseBox));
public static readonly DependencyProperty HasItemsProperty = HasItemsPropertyKey.DependencyProperty;
public bool HasItems => (bool) GetValue(HasItemsProperty);
protected virtual void Refresh()
{
if (ItemsHost == null) return;