<DataTemplate x:Name="SoundTitleTemplate">
<ProgressBar x:Name="bar" Visibility="Visible" Height="0" Margin="20,30,130,0" />
</DataTemplate>
在CS中
private void _webClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
try
{
if (_downloadCanceled)
return;
if (bar.Value <= bar.Maximum)
{
bar.Value = e.ProgressPercentage;
bar.Text = string.Format("{0}%", e.ProgressPercentage);
}
}
}
我搜索了任何此主题,但没有获得帮助:(如果你有什么方法,请告诉我,我试了一下我发现的,最后都是失败的~.~
这个答案可以帮助你: 如何在数据模板中获得控制权?
还有关于在 DataTemmplate 中访问 cotrol 的文章(但对于 WPF(:
http://blogs.msdn.com/b/wpfsdk/archive/2007/04/16/how-do-i-programmatically-interact-with-template-generated-elements-part-ii.aspx