Fdream's Blog
专注于WEB前端开发
Powered by Google

返回指定Canvas中的所有TextBlock

4 雨天 2007-9
Fdream 发表于 Silverlight, 已被阅读 16789 次, 评论 0 条
关键词:Silverlight
[ 阅读字体大小: ]

还是因为要用中文,所以需要遍历所有的TextBlock,一一设置字体……还好,不算复杂,先找根Canvas中的节点,如果是TextBlock就加入到List中,如果是Canvas的话就递归一次,然后把返回结果也加入到List中,最终返回一个TextBlock数组。

引用内容:

TextBlock[] FindAllTextBlock(Canvas container)

{

List<TextBlock> tbl = new List<TextBlock>();

for (int i = 0; i < container.Children.Count; i++)

{

//如果是TextBlock,就加入到List中

if (container.Children.GetType() == typeof(TextBlock))

tbl.Add(container.Children as TextBlock);

//如果是Canvas,就继续递归查找

else if (container.Children.GetType() == typeof(Canvas))

tbl.AddRange(FindAllTextBlock(container.Children as Canvas));

}

return tbl.ToArray();

}

Related articles 您可能对这些文章也感兴趣:
Related comments 与该文相关的评论:(我也想说几句)
Add a comment 我来说两句: 
禁止表情
禁止UBB
禁止图片
识别链接
识别关键字
表  情
arrow
用户名:   密码:  (匿名可不写) 同时注册?
验证码:   看不清?换个图片  看不清楚?换个图片

 
Copyright © 2005-2008,Fdream All Rights Reserved
Processed in 0.0781265 second(s) , unknow queries
Powered by OWord V0.1, Even Not Alpha
(此博客程序为半成品,请勿索取,以免给您的心灵造成创伤^_^)
鄂ICP备05026031号