0
<DataTemplate x:Name="SoundTitleTemplate">
<ProgressBar x:Name="bar" Visibility="Visible" Height="0" Margin="20,30,130,0" />
</DataTemplate>
在CS
爲什麼我不能在代碼後面得到「bar」?因爲我放入數據模板?我如何進入?
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);
}
}
}
我得到任何搜索這個話題,但沒有獲得幫助:( 如果您有任何方法,請告訴我,我嘗試我發現了什麼,到底是失敗的〜 。〜
您不使用過程代碼「訪問」XAML中的「DataTemplate」內的UI元素。改用DataBinding。 –
如何做到這一點?我聽起來很難... – user3064311
不太難:http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207023%28v=vs.105%29.aspx –