Xaml 如果observablecollection为null,如何隐藏Textblock
如果绑定observablecollection包含空,是否可以使用xaml代码隐藏TextBlock?xamlXaml 如果observablecollection为null,如何隐藏Textblock,xaml,Xaml,如果绑定observablecollection包含空,是否可以使用xaml代码隐藏TextBlock?xaml <TextBlock Visibility="{Binding ElementName=Labour,Path=Items.Count, Converter={StaticResource ZeroToVisibilityConverter}}" TextWrapping="Wrap" Text="There is no data on this date" Margin="3
<TextBlock Visibility="{Binding ElementName=Labour,Path=Items.Count, Converter={StaticResource ZeroToVisibilityConverter}}" TextWrapping="Wrap" Text="There is no data on this date" Margin="314,200,0,0" FontFamily="Arial" FontSize="14" Height="37" VerticalAlignment="Top" HorizontalAlignment="Left" Width="188"/>
public class ZeroToVisibilityConverter : IValueConverter
{
#region Implementation of IValueConverter
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return int.Parse(value.ToString()) == 0 ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}