public object Convert(object value, Type targetType, object parameter, Culture culture) { // Validate if (!(value is Location)) { throw new InvalidOperationException("Only Location is supported as a source."); } if (targetType != typeof(Visibility)) { throw new InvalidOperationException("Only Visibility is supported as the target type"); } // Cast to proper types Location loc = (Location)value; // If it's unknown the item shouldn't be shown if (loc.IsUnknown()) { return(Visibility.Collapsed); } else { return(Visibility.Visible); } }