private void PaintField() { //DataContext нужен для работы привязки компонентов формы к текущему объекту VisualEquation visualEquation; if (!(DataContext is VisualEquation) || DataContext == null) { visualEquation = new VisualEquation(MainPaintField, 0, 0, 1, Equation); DataContext = visualEquation; } else { visualEquation = (VisualEquation)DataContext; visualEquation.PaintField(); visualEquation.DrawEquation(); } }
public MainWindow() { InitializeComponent(); DataContext = null; this.Loaded += WindowLoaded; this.SizeChanged += WindowSizeChanged; this.MinHeight = 350; this.MouseWheel += (obj, arg) => { if (DataContext is VisualEquation && DataContext != null) { VisualEquation equation = (VisualEquation)DataContext; if (arg.Delta > 0) { equation.PaintStep++; } else if (arg.Delta < 0) { equation.PaintStep--; } } }; }