好的,所以我试图在集合为空时显示一条非常简单的消息。在我第二次访问之后,它只在一个数据透视页面项目上工作...真的想要一个优雅的解决方案。感觉我在这里错过了一些非常简单的东西。
在我的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}" />
答案 0 :(得分:3)
您还需要为EmptyMessage引发更改事件,如下所示:
public bool IsDataLoaded
{
get
{
return _IsDataLoaded;
}
set
{
_IsDataLoaded = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("IsDataLoaded"));
PropertyChanged(this, new PropertyChangedEventArgs("EmptyMessage"));
}
}
}