【发布时间】:2012-08-04 12:20:07
【问题描述】:
我一直在研究,并且一直在尝试不同的方式在我的列表框为空时显示消息。
按照这篇文章做的 WPF Listbox - Empty List Display Message
没有运气在我的视图模型中添加了代码,我的文本块锁定如下:
<TextBlock Text="{Binding EmptyMessage}" Visibility="{Binding Converter={StaticResource VisibilityConverter}, Path=allToDoItemsListBox.Count}" FontSize="{StaticResource PhoneFontSizeExtraLarge}" IsHitTestVisible="False" />
还做了一个这样的转换器:
公共类 VisibilityConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null && (int)value > 0)
return "Collapsed";
else
return "Visible";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
我缺少什么,应该可以工作,但不能。已将 app.xanl 中的转换器添加为资源
【问题讨论】:
-
如果 (int)value > 0,你的列表框不应该是可见的,而不是像你做的那样相反吗?
-
没有。它的意思是如果 (int) 值大于 0,在这种情况下应该将可见性设置为 Collapsed。
标签: windows-phone-7 listbox message