From d0c978b71c519a0d9c0fd16f596dfea441fc1666 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 13 Aug 2019 10:51:04 -0500 Subject: [PATCH] ColorPickerPopupVM initailizes palettes lazily --- .../spark/view/Controls/ColorPicker/ColorPickerPopup.xaml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/spark/view/Controls/ColorPicker/ColorPickerPopup.xaml.cs b/src/client/spark/view/Controls/ColorPicker/ColorPickerPopup.xaml.cs index a3e568fcd..a55734853 100644 --- a/src/client/spark/view/Controls/ColorPicker/ColorPickerPopup.xaml.cs +++ b/src/client/spark/view/Controls/ColorPicker/ColorPickerPopup.xaml.cs @@ -40,18 +40,18 @@ namespace mbts.ui.controls { class ColorPickerPopupVM : ViewModelBase, IValueFactory { readonly Property _color; readonly Property _opacity; + ObservableCollection _palettes; bool _bind_opacity_to_alpha; IDisposable _opacity_alpha_binding; public ColorPickerPopupVM() { _color = backing(nameof(color), Colors.Black); _opacity = backing(nameof(opacity), 1.0); - palettes = new ObservableCollection(ColorPalette.all_presets().Select(p => new ColorPaletteVM(p))); } public Color color { get => _color.Value; set => _color.set(value); } public double opacity { get => _opacity.Value; set => _opacity.set(value); } - public ObservableCollection palettes { get; } + public ObservableCollection palettes => _palettes ?? (_palettes = new ObservableCollection(ColorPalette.all_presets().Select(p => new ColorPaletteVM(p)))); public bool bind_opacity_to_alpha { get => _bind_opacity_to_alpha; set {