Customizing ListBox and ComboBox
Introduction
Customizing Using VisualTemplate
var listBox = new ListBox();
listBox.AddToRoot();
listBox.Anchor(Anchor.Center);
listBox.VisualTemplate = new VisualTemplate(() =>
{
var visual = new ListBoxItemVisual();
visual.ForegroundColor = Color.Yellow;
visual.HighlightedBackgroundColor = Color.DarkGreen;
visual.SelectedBackgroundColor = Color.Green;
return visual;
});
for(int i = 0; i < 20; i++)
{
listBox.Items.Add($"Item {i}");
}

Last updated
Was this helpful?

