// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using Perspex.Controls.Generators;
using Perspex.Controls.Primitives;
using Perspex.Input;
namespace Perspex.Controls
{
///
/// An in which individual items can be selected.
///
public class ListBox : SelectingItemsControl
{
///
/// Defines the property.
///
public static readonly new PerspexProperty SelectionModeProperty =
SelectingItemsControl.SelectionModeProperty;
///
public new SelectionMode SelectionMode
{
get { return base.SelectionMode; }
set { base.SelectionMode = value; }
}
///
protected override IItemContainerGenerator CreateItemContainerGenerator()
{
return new ItemContainerGenerator(this);
}
///
protected override void OnGotFocus(GotFocusEventArgs e)
{
base.OnGotFocus(e);
if (e.NavigationMethod == NavigationMethod.Directional)
{
e.Handled = UpdateSelectionFromEventSource(
e.Source,
true,
(e.InputModifiers & InputModifiers.Shift) != 0);
}
}
///
protected override void OnPointerPressed(PointerPressEventArgs e)
{
base.OnPointerPressed(e);
if (e.MouseButton == MouseButton.Left || e.MouseButton == MouseButton.Right)
{
e.Handled = UpdateSelectionFromEventSource(
e.Source,
true,
(e.InputModifiers & InputModifiers.Shift) != 0,
(e.InputModifiers & InputModifiers.Control) != 0);
}
}
}
}