private void PropertiesViewModelHandler(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != "SelectedLayerType")
return;
// Store the brush in case the user wants to reuse it
var oldBrush = ProposedLayer.Properties.Brush;
// Update the model
if (ProposedLayer.LayerType.GetType() != SelectedLayerType.GetType())
{
ProposedLayer.LayerType = SelectedLayerType;
ProposedLayer.SetupProperties();
}
// Let the layer type handle the viewmodel setup
LayerPropertiesViewModel = ProposedLayer.LayerType.SetupViewModel(this, LayerPropertiesViewModel);
if (oldBrush != null)
ProposedLayer.Properties.Brush = oldBrush;
NotifyOfPropertyChange(() => LayerPropertiesViewModel);
}