首页 新闻 会员 周边 捐助

关于Silverlight中获取Children的问题

0
[已关闭问题]

请问我怎么通过后台编程来获取Name为ChartArea这个Grid,通过VisualTreeHelper.GetChildrenCount(Charts)返回值为“0”,请问为什么不是1?谢谢!

代码如下:

 

<UserControl x:Class="PlotLine.Page"
xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:charting
="clr-namespace:Microsoft.Windows.Controls.DataVisualization.Charting;assembly=Microsoft.Windows.Controls.DataVisualization"
xmlns:datavis
="clr-namespace:Microsoft.Windows.Controls.DataVisualization;assembly=Microsoft.Windows.Controls.DataVisualization">
<UserControl.Resources>
<!-- styles -->
<Style x:Key="PlotAreaStyle" TargetType="Grid">
<Setter Property="Background" Value="White"/>
</Style>
<Style x:Key="GridLineStyle" TargetType="Line">
<Setter Property="Stroke" Value="LightGray"/>
</Style>
</UserControl.Resources>
<charting:Chart Name="Charts" Width="auto" Height="auto" PlotAreaStyle="{StaticResource PlotAreaStyle}">
<charting:Chart.Template>
<ControlTemplate TargetType="charting:Chart" x:Name="ChartTemplate" >
<Grid x:Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}" >
<Grid Name="PlotArea" Style="{TemplateBinding PlotAreaStyle}">
<Grid x:Name="GridLinesContainer" />
<Path Fill="#FFFFFFFF" Stretch="UniformToFill" Stroke="#FF000000" Data="M36,32 C44.465485,13.278256 46.24641,0.49792495 80,20"/>
</Grid>
</Grid>
</ControlTemplate>
</charting:Chart.Template>
<charting:Chart.Axes>
<charting:LinearAxis Orientation="Vertical" ShowGridLines="True" Title="Y轴"
GridLineStyle
="{StaticResource GridLineStyle}" />
<charting:LinearAxis Orientation="Horizontal" ShowGridLines="True" Title="X轴" Maximum="100" Minimum="0"
GridLineStyle
="{StaticResource GridLineStyle}" />
</charting:Chart.Axes>
</charting:Chart>
</UserControl>

 

 

菜鸟老师的主页 菜鸟老师 | 初学一级 | 园豆:160
提问于:2009-04-20 22:53
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册