// ----------------------------------------------------------------------- // // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- namespace Perspex.Themes.Default { using Perspex.Controls; using Perspex.Controls.Presenters; using Perspex.Media; using Perspex.Styling; using System.Linq; public class ListBoxStyle : Styles { public ListBoxStyle() { this.AddRange(new[] { new Style(x => x.OfType()) { Setters = new[] { new Setter(ListBox.TemplateProperty, ControlTemplate.Create(this.Template)), new Setter(ListBox.BorderBrushProperty, Brushes.Black), new Setter(ListBox.BorderThicknessProperty, 1.0), }, }, }); } private Control Template(ListBox control) { return new Border { Padding = new Thickness(4), [~Border.BackgroundProperty] = control[~ListBox.BackgroundProperty], [~Border.BorderBrushProperty] = control[~ListBox.BorderBrushProperty], [~Border.BorderThicknessProperty] = control[~ListBox.BorderThicknessProperty], Child = new ScrollViewer { Content = new ItemsPresenter { Name = "itemsPresenter", [~ItemsPresenter.ItemsProperty] = control[~ListBox.ItemsProperty], [~ItemsPresenter.ItemsPanelProperty] = control[~ListBox.ItemsPanelProperty], } } }; } } }