开发者

Windows Phone 7 Empty Data message for Listbox?

OK, so I'm trying to get a really simple message to display when a collection is empty. It's only working on a pivot page item after the 2nd time I visit... Would really like an elegant solution to this. It feels like I'm missing something really simple here.

inside my 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;
    }

here is the xaml....

    &开发者_Go百科lt;TextBlock Text="{Binding EmptyMessage}" Visibility="{Binding Converter={StaticResource CollectionLengthToVisibilityConverter1}, Path=VitalSigns.Count}" FontSize="{StaticResource PhoneFontSizeExtraLarge}" />


You would also need to raise a change event for your EmptyMessage, like so:

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜