public LegendOptionsWindow(MapLegend legend) { InitializeComponent(); Legend = legend; DataContext = this; BackgroundColor = Legend.BackgroundColor; BorderColor = Legend.BorderColor; BorderWidth = Legend.BorderWidth; LegendTitle = Legend.Title; TitleFont = Legend.TitleFont; NumberOfColumns = Legend.NumberOfColumns; ItemFont = Legend.ItemFont; Layers = new List <LegendItemDescriptorViewModel>(); foreach (LegendItemDescriptor desc in legend.GetLayerDescriptors().Values) { var model = new LegendItemDescriptor { IsVisible = desc.IsVisible, LayerName = desc.LayerName, Title = desc.Title, TitleColor = desc.TitleColor }; var viewModel = new LegendItemDescriptorViewModel(model); Layers.Add(viewModel); viewModel.DataChanged += viewModel_DataChanged; } Layers.Sort((a, b) => String.CompareOrdinal(a.LayerName, b.LayerName)); Loaded += (sender, e) => { if (lstLayers.Items.Count > 0) { lstLayers.SelectedIndex = 0; } }; GraphicsUtils.ApplyLegacyFont(lblTitleFont, TitleFont); GraphicsUtils.ApplyLegacyFont(lblItemFont, ItemFont); btnApply.IsEnabled = false; PropertyChanged += LegendOptionsWindow_PropertyChanged; }