且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WPF中将四个数字字符串值(比如:"10,10,300,300")转为Rect

更新时间:2022-09-13 18:47:48

原文:WPF中将四个数字字符串值(比如:"10,10,300,300")转为Rect

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";
}