XamlReader.Load

本来蛮简单的一个用法,却在实用中折腾了半天,原因就一个属性没写xmlns='http://schemas.microsoft.com/client/2007',否则就一直报错,不知所以,正确用法为:

Xaml代码为:
            string _Xaml=
                "<PathGeometry  xmlns='http://schemas.microsoft.com/client/2007'>" +
                "<PathFigure StartPoint='0,0'>" +
                "<LineSegment />" +
                "</PathFigure>" +
                "</PathGeometry>";
PathGeometry myGEO= XamlReader.Load(xaml) as PathGeometry;

又解决了一个问题:
如果需要引用动态创建的控件,需要注意不能在XAML代码中使用x:Name属性,通过为其指定Name属性,并使用FindName方法,就可以完成对动态创建的控件的引用。

posted @ 2008-05-19 09:01 星际 阅读(188) 评论(0)  编辑 收藏 网摘 所属分类: 学习心得



发表评论

昵称: [登录] [注册]

主页:

邮箱:(仅博主可见)

评论内容:

  登录  注册

[使用Ctrl+Enter键快速提交评论]

0 1202318




相关文章:

相关链接: