// -----------------------------------------------------------------------
//
// Copyright 2014 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Controls
{
using System;
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Perspex.Collections;
using Perspex.Controls.Generators;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Controls.Utils;
using Perspex.Styling;
///
/// Displays a collection of items.
///
public class ItemsControl : TemplatedControl, IReparentingHost
{
///
/// The default value for the property.
///
[SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1202:ElementsMustBeOrderedByAccess", Justification = "Needs to be before or a NullReferenceException is thrown.")]
private static readonly ItemsPanelTemplate DefaultPanel =
new ItemsPanelTemplate(() => new StackPanel());
///
/// Defines the property.
///
public static readonly PerspexProperty ItemsProperty =
PerspexProperty.Register("Items");
///
/// Defines the property.
///
public static readonly PerspexProperty ItemsPanelProperty =
PerspexProperty.Register("ItemsPanel", defaultValue: DefaultPanel);
private IItemContainerGenerator itemContainerGenerator;
///
/// Initializes static members of the class.
///
static ItemsControl()
{
ItemsProperty.Changed.AddClassHandler(x => x.ItemsChanged);
}
///
/// Initializes a new instance of the class.
///
public ItemsControl()
{
this.Classes.Add(":empty");
this.Items = new PerspexList