private void Diagramcontrol_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Theme") { if (cacheTheme != null) { cacheTheme.PropertyChanged -= DiagramTheme_PropertyChanged; cacheTheme = null; } if (((SfDiagram)sender).Theme != null) { cacheTheme = ((SfDiagram)sender).Theme; stencil.DiagramTheme = Activator.CreateInstance(cacheTheme.GetType()) as DiagramTheme; cacheTheme.PropertyChanged += DiagramTheme_PropertyChanged; } } }
private void DiagramVM_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Theme") { if (cacheTheme != null) { cacheTheme.PropertyChanged -= DiagramTheme_PropertyChanged; cacheTheme = null; } if ((StencilView as Grid).Children.Count > 0) { var stencil = (StencilView as Grid).Children[0]; cacheTheme = DiagramVM.Theme; if (cacheTheme != null) { if (stencil is IStencilTheme) { (stencil as IStencilTheme).Theme = Activator.CreateInstance(cacheTheme.GetType()) as DiagramTheme; } cacheTheme.PropertyChanged += DiagramTheme_PropertyChanged; } } } }