Yes. Bind the ListBox's Visibility property to the object that contains the array. Then apply a custom value converter that will look at the array and see if it is empty. If it is empty, return Visibility.Collapsed. Otherwise, return Visibility.Visible. Then make sure your RowDefinition has a height of Auto, and it will automatically shrink to nothing when the ListBox is collapsed.
Your value converter will look something like this:
public class EmptyVisiblityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
YourObject yourObject = value as YourObject;
return yourObject.YourArray.Count > 0 ? Visibility.Visible : Visibility.Hidden;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
}
And your XAML should look something like this:
<Window.Resources>
<local:EmptyVisiblityConverter x:Key="emptyVisibilityConverter"/>
</Window.Resources>
...
<ListBox Visibility="{Binding Path=YourObject, Converter={StaticResource emptyVisibilityConverter}}"/>