WPF Path.Data值设定

来源:互联网 发布:cocos2dx for mac 编辑:程序博客网 时间:2024/04/30 04:12
        /// <summary>
        /// Path.Data值取得
        /// </summary>
        /// <param name="pathMarkup"></param>
        /// <returns></returns>
        public Geometry PathMarkupToGeometry(string pathMarkup)
        {
            string xaml =
            "<Path " +
            "xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'>" +
            "<Path.Data>" + pathMarkup + "</Path.Data></Path>";
            StringReader stringReader = new StringReader(xaml);
            XmlReader xmlReader = XmlReader.Create(stringReader);
            var path = XamlReader.Load(xmlReader) as System.Windows.Shapes.Path;
            // Detach the PathGeometry from the Path
            Geometry geometry = path.Data;
            path.Data = null;
            return geometry;
        }
0 0