void AddMask() { if (tmpRect.ActualWidth != 0 && tmpRect.ActualHeight != 0) { RectMarkers.Add(tmpRect); MainWindow mv = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); double x = Canvas.GetLeft(tmpRect); double y = Canvas.GetTop(tmpRect); tmpText = DrawCanvas.Text(x, y, (TextMarkers.Count + 1).ToString(), true, Brushes.Yellow, mv.CanvasResult, false); TextMarkers.Add(tmpText); tmpRect = new Rectangle(); tmpText = new TextBlock(); OnPropertyChanged("MaskCounts"); } }