开发者

How to get Firefox to not continue to show "Transferring data from..." in browser status bar after async data is loaded?

The following silverlight demo loads and displays a text file from a server.

However, in Firefox (but not Explorer or Chrome) after you click the button and the text displays, the status bar continues to show "Transferring data from test.development..." which erroneously gives the user the belief that something is still loading.

I've noticed that if you click on another Firefox tab and then back on the original one, the message goes away, so it seems to be just a Firefox bug that doesn't clear the status bar automatically.

Is there a way to clear the status bar automatically in Firefox? or a way to explicitly tell it that the async loading is finished so it can clear the status bar itself?

XAML:

<UserControl x:Class="TestLoad1111.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <StackPanel Margin="10">
        <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Margin="0 0 0 10">
            <Button Content="Load Text" Click="Button_LoadText_Click"/>
        </StackPanel>
        <TextBlock Text="{Binding Message}" />
    </StackPanel>
</UserControl>

Code Behind:

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.ComponentModel;

namespace TestLoad1111
{
    public partial class MainPage : UserControl, INotifyPropertyChanged
    {
        #region ViewModelProperty: Message
        private string _message;
        public string Message
        {
            get
            {
                return _message;
            }

            set
            {
                _message = value;
                OnPropertyChanged("Message");
            }
        }
        #endregion

        public MainPage()
        {
            InitializeComponent();
            DataContext = this;
        }

        private void Button_LoadText_Click(object sender, RoutedEventArgs e)
        {
            WebClient webClientTextLoader = new WebClient();
            webClientTextLoader.DownloadStringAsync(new Uri("http://test.development:111/testdata/test.txt?" + Helpers.GetRandomizedSuffixToPreventCaching()));
            webClientTextLoader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClientTextLoader_DownloadStringCompleted);
        }


        void webClientTextLoader_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            Message = e.Result;
        }

        #region INotifiedProperty Block
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion
    }

    public static class Helpers
    {
        private static Random ra开发者_如何学Pythonndom = new Random();
        public static int GetRandomizedSuffixToPreventCaching()
        {
            return random.Next(10000, 99999);
        }
    }
}


The best way would be to file a bug on Firefox's bug tracking system, and wait until they fix it. You'll need to create an account there, however. There's a chance that your problem is related to the problem with flash and AJAX.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜