Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为什么我能';我得不到;酒吧;代码隐藏?因为我加入了数据模板?我如何访问?_C#_Xaml_Windows Phone 8_Computer Science - Fatal编程技术网

C# 为什么我能';我得不到;酒吧;代码隐藏?因为我加入了数据模板?我如何访问?

C# 为什么我能';我得不到;酒吧;代码隐藏?因为我加入了数据模板?我如何访问?,c#,xaml,windows-phone-8,computer-science,C#,Xaml,Windows Phone 8,Computer Science,在cs中 private void\u webClient\u DownloadProgressChanged(对象发送方,DownloadProgressChangedEventArgs e) { 尝试 { 如果(下载已取消) 返回; 如果(bar.Value此答案可以帮助您: 另外还有一篇关于在DataTemplate中访问cotrol的文章(但对于WPF): 在XAML中,您不能使用过程代码“访问”数据模板中的UI元素。请改用数据绑定。如何做到这一点?我听起来很难…不太难: <Da

在cs中

private void\u webClient\u DownloadProgressChanged(对象发送方,DownloadProgressChangedEventArgs e)
{
尝试
{
如果(下载已取消)
返回;

如果(bar.Value此答案可以帮助您:

另外还有一篇关于在DataTemplate中访问cotrol的文章(但对于WPF):


在XAML中,您不能使用过程代码“访问”数据模板中的UI元素。请改用数据绑定。如何做到这一点?我听起来很难…不太难:
 <DataTemplate x:Name="SoundTitleTemplate"> 
    <ProgressBar x:Name="bar" Visibility="Visible" Height="0" Margin="20,30,130,0" />
 </DataTemplate>
    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);
            }

        }

    }