title: Visibility against the collection of items in WPF
body: <p>I have dropdown and Grid. in the grid column there is hyperlink.If the Dropdown collection contains 1 item then the dropdown should be  invisible.I meean need a logic to bind Visibility against the collection of items.</p>
  
  <p>Here is the XAML for one Hyperlink in the GRid.</p>
  
  <pre><code>   &lt;!--Associate--&gt;
                      &lt;TextBlock Margin="10, 0, 0, 0"&gt;                                    
                          &lt;TextBlock.Visibility&gt;                                           
                                   &lt;MultiBinding Converter="{StaticResource courseListVisibilityConverter}"
                                                       ConverterParameter="Associate"&gt;
                                            &lt;Binding Path="IsCourseAssocited"
                                                     RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType={x:Type DPA2:TakenCoursesNotApplied}}" /&gt;
                                              &lt;Binding Path="DataContext"
                                                       RelativeSource="{RelativeSource Self}" /&gt;
                                         &lt;/MultiBinding&gt;
                              &lt;/TextBlock.Visibility&gt;
  
                          &lt;Hyperlink DataContext="{Binding}"
                                     Name="Associate"
                                      IsEnabled="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TextBlock}}, Path=IsVisible}"
                                      Click="Associate_Click"&gt;
                              &lt;TextBlock TextWrapping="Wrap"
                                          Text="Associate" /&gt;
                          &lt;/Hyperlink&gt;
                      &lt;/TextBlock&gt;
  
   public class CourseListVisibilityConverter : IMultiValueConverter
  {
      public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
      {
          if (value == null || value[0] == null || value[1] == null) return Visibility.Collapsed;
          bool IsEditMode = value[0] == DependencyProperty.UnsetValue ? false : (bool)value[0];
  
          if (value[1].GetType() == typeof(Course))
          {
              Course course = value[1] as Course;
              if (course == null) return string.Empty;
  
              //Visibility retVal = Visibility.Visible;
              switch (parameter.ToString())
              {
                  case "CodeLink":
                      if (!IsEditMode) return Visibility.Collapsed;
                      if (course.HideOptions) return Visibility.Collapsed;
                      if (course.IsInElectivePool &amp;&amp;
                          course.IsManualAdd) return Visibility.Visible;
                      if (!course.IsInElectivePool &amp;&amp;
                              !course.IsWaived) return Visibility.Visible;
  
                      if (course.IsInElectivePool &amp;&amp;
                          course.FulFillmentId != 0 &amp;&amp;
                          course.FulFillmentId != -1 &amp;&amp;
                          !course.IsWaived) return Visibility.Visible;
  
                      return Visibility.Collapsed;
  
                  case "CodeNoLink":
                      if (!IsEditMode) return Visibility.Visible;
                      if (course.HideOptions) return Visibility.Visible;
  
                      if (course.IsInElectivePool &amp;&amp;
                          course.IsManualAdd) return Visibility.Collapsed;
                      if (!course.IsInElectivePool &amp;&amp;
                            !course.IsWaived) return Visibility.Collapsed;
  
                      if (course.IsInElectivePool &amp;&amp;
                          course.FulFillmentId != 0 &amp;&amp;
                          course.FulFillmentId != -1 &amp;&amp;
                          !course.IsWaived) return Visibility.Collapsed;
  
                      return Visibility.Visible;
  
                  case "Waive":
                      if (course.HideOptions) return Visibility.Collapsed;
                      if (IsEditMode &amp;&amp;
                          !course.IsWaived &amp;&amp;
                           !(course.RetakenFlag == RetakeFlagType.RetakeOfCourse) &amp;&amp;
                          !course.IsInElectivePool) return Visibility.Visible;
                      return Visibility.Collapsed;
  
                  case "UndoWaive":
                      if (course.HideOptions) return Visibility.Collapsed;
                      if (IsEditMode &amp;&amp; course.IsWaived &amp;&amp;
                            !(course.RetakenFlag == RetakeFlagType.RetakeOfCourse) &amp;&amp;
                          !course.IsInElectivePool) return Visibility.Visible;
                      return Visibility.Collapsed;
  
                  case "UndoAdd":
                      if (course.HideOptions) return Visibility.Collapsed;
                      if (IsEditMode &amp;&amp; course.IsManualAdd &amp;&amp;
                          (!(course.RetakenFlag == RetakeFlagType.RetakeOfCourse) &amp;&amp;
                           !course.IsInElectivePool)) return Visibility.Visible;
                      return Visibility.Collapsed;
                  case "Associate":
                      if (course.HideOptions) return Visibility.Collapsed;
                      if (IsEditMode &amp;&amp; course.IsCourseAssocited)
                          return Visibility.Collapsed;
                      else if (IsEditMode &amp;&amp;
                          ((course.Status.ToUpper() == "COMPLETE" || course.Status.ToUpper() == "DROPPED")))
                      {
                          return Visibility.Visible;
                      }
                      else
                      {
                          return Visibility.Collapsed;
                      }
                  //case "UnAssociate":
                  //    if (course.HideOptions) return Visibility.Collapsed;
                  //    if (IsEditMode &amp;&amp; (course.IsCourseAssocited))
  
                  //    {
                  //        return Visibility.Visible;
                  //    }
                  //    else
                  //    {
                  //        return Visibility.Collapsed;
                  //    }
                  case "FullFillRequirement":
                      if (course.HideOptions) return Visibility.Collapsed;
                      if (IsEditMode &amp;&amp;
                          ((course.Status.ToUpper() == "FUTURE")))
                      {
                          return Visibility.Visible;
                      }
                      else
                      {
                          return Visibility.Collapsed;
                      }
                  default:
                      return Visibility.Collapsed;
              }
          }
          else if (value[1].GetType() == typeof(ElectivePool))
          {
              ElectivePool electivePool = value[1] as ElectivePool;
              if (electivePool == null) return string.Empty;
  
              switch (parameter.ToString())
              {
                  case "Waive":
  
                      if (IsEditMode &amp;&amp;
                          !electivePool.IsWaived) return Visibility.Visible;
                      return Visibility.Collapsed;
  
                  case "UndoWaive":
                      if (IsEditMode &amp;&amp;
                          electivePool.IsWaived) return Visibility.Visible;
                      return Visibility.Collapsed;
              }
          }
          return Visibility.Visible;
      }
  
      public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
      {
          throw new NotSupportedException();
      }
  }
  </code></pre>