由于界面很多要控制的控件,所以就采用了VisualTreeHelper.GetChild()等等方法来找,根据名称来匹配。var count = VisualTreeHelper.GetChildrenCount(element);但是今天在界面上加了ScrollViewer后,问题出来了,上一行代码中ScrollViewer 的count始终都是0,结果特殊处理了以下,遇到ScrollViewer,将ScrollViewer的Content去找,结果可以了。大概可以猜到了,内容控件ContentControl,在VisualTree就是叶子节点了,内容和它本身是一个整体,所以VisualTr Read More
posted @ 2012-06-13 15:31 321程序员 Views(1664) Comments(0) Diggs(1)
<UserControl xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" xmlns:Common="clr-namespace:System.Windows;assembly=System.Windows.Controls" x:Class="SilverlightApplication1.Page1" xmlns="http://schemas.microsoft.com/winfx/20 Read More
posted @ 2012-05-23 17:05 321程序员 Views(1064) Comments(1) Diggs(1)