Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.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# Windows Phone 7列表框的空数据消息?_C#_Windows_Silverlight_Windows Phone 7 - Fatal编程技术网

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

C# Windows Phone 7列表框的空数据消息?,c#,windows,silverlight,windows-phone-7,C#,Windows,Silverlight,Windows Phone 7,好的,所以我尝试在集合为空时显示一条非常简单的消息。它只在我第二次访问后处理透视页项目。。。我真的想要一个优雅的解决方案。我觉得我错过了一些非常简单的事情 在我的ViewModel中 private bool _IsDataLoaded; public bool IsDataLoaded { get { return _IsDataLoaded; } set {

好的,所以我尝试在集合为空时显示一条非常简单的消息。它只在我第二次访问后处理透视页项目。。。我真的想要一个优雅的解决方案。我觉得我错过了一些非常简单的事情

在我的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引发一个更改事件,如下所示:

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

哇,我就知道这会很简单!谢谢@Code裸体!