系统相关
首页 > 系统相关> > 列表框的Windows Phone 7空数据消息?

列表框的Windows Phone 7空数据消息?

作者:互联网

好的,所以我想让一个非常简单的消息在集合为空时显示.在我第二次访问后,它仅在数据透视页项目上起作用.感觉好像我在这里错过了一些非常简单的事情.

在我的ViewModel中…

    private bool _IsDataLoaded;
    public bool IsDataLoaded
    {
        get
        {
            return _IsDataLoaded;
        }
        set
        {
            _IsDataLoaded = value;
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("IsDataLoaded"));
            }
        }
    }

    public string EmptyMessage
    {
        get
        {
            if (IsDataLoaded)
            {
                return "No Tips for this Venue.";
            }
            else
            {
                return "";
            }
        }
    }

    ........

     void clientGetTips_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        ...

        this.IsDataLoaded = true;
    }

这是xaml ….

    <TextBlock Text="{Binding EmptyMessage}" Visibility="{Binding Converter={StaticResource CollectionLengthToVisibilityConverter1}, Path=VitalSigns.Count}" FontSize="{StaticResource PhoneFontSizeExtraLarge}" />

解决方法:

您还需要为EmptyMessage引发一个change事件,如下所示:

public bool IsDataLoaded
{
    get
    {
        return _IsDataLoaded;
    }
    set
    {
        _IsDataLoaded = value;
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs("IsDataLoaded"));
            PropertyChanged(this, new PropertyChangedEventArgs("EmptyMessage"));
        }
    }
}

标签:windows-phone-7,windows,c,silverlight
来源: https://codeday.me/bug/20191208/2090190.html