csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.9 KiB
53 lines
1.9 KiB
// -----------------------------------------------------------------------
|
|
// <copyright file="ListBoxStyle.cs" company="Steven Kirk">
|
|
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|
// </copyright>
|
|
// -----------------------------------------------------------------------
|
|
|
|
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<ListBox>())
|
|
{
|
|
Setters = new[]
|
|
{
|
|
new Setter(ListBox.TemplateProperty, ControlTemplate.Create<ListBox>(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],
|
|
Content = new ScrollViewer
|
|
{
|
|
Content = new ItemsPresenter
|
|
{
|
|
Name = "itemsPresenter",
|
|
[~ItemsPresenter.ItemsProperty] = control[~ListBox.ItemsProperty],
|
|
[~ItemsPresenter.ItemsPanelProperty] = control[~ListBox.ItemsPanelProperty],
|
|
}
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|