RectConverter rectConverter = new RectConverter(); string parseString = viewportEntry.Text; if (parseString != null && parseString != string.Empty) { imageBrush.Viewport = (Rect)rectConverter.ConvertFromString(parseString); } else { imageBrush.Viewport = Rect.Empty; viewportEntry.Text = "Empty"; }