title: C# PickList values to ComboBox (AutoTask API, Multi-Key Dictionaries)
body: <p>I am currently coding a few things for an AutoTask implementation using the AT web services API (<a href="https://webservices5.autotask.net/ATServices/1.5/atws.asmx" rel="nofollow">https://webservices5.autotask.net/ATServices/1.5/atws.asmx</a>). To do anything you basically need to query AT for all of the picklist values first. This is fairly straight forward, however I'm having some trouble figuring out how to separate all of the "SubIssueTypes" so they can easily be linked to their parent value "IssueType". </p>
  
  <p>I have been putting each PickList into a Dictionary, and making that dictionary the source for ComboBoxes within the application. This works great, except I'm not sure what the best way to do SubIssueTypes. Each IssueType has multiple SubIssueTypes linked to it, however AT has placed all of the SubIssueTypes in the same PickList.</p>
  
  <p>How can I place all of the SubIssueTypes into their own ComboBox that only shows the values who's "pValue.parentValue" matches the currently selected IssueType value? </p>
  
  <pre><code>public static Dictionary&lt;string, Resource&gt; ResourcesById = new Dictionary&lt;string, Resource&gt;();
  public static Dictionary&lt;string, Account&gt; AccountsById = new Dictionary&lt;string, Account&gt;();
  public static Dictionary&lt;string, string&gt; ResourcesIdByName = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, string&gt; AccountsIdByName = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, string&gt; AccountsNameById = new Dictionary&lt;string, string&gt;();
  
  public static Dictionary&lt;string, string&gt; StatusIdByName = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, string&gt; StatusNameById = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, string&gt; IssueType = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, string&gt; SubIssueType = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, Tuple&lt;string, string&gt;&gt; SubIssueLabel = new Dictionary&lt;string, Tuple&lt;string, string&gt;&gt;();
  public static Dictionary&lt;Tuple&lt;string, string&gt;, string&gt; SubIssueValue = new Dictionary&lt;Tuple&lt;string, string&gt;, string&gt;();
  public static Dictionary&lt;string, string&gt; Priority = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, string&gt; Source = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, string&gt; ServiceLevelAgreement = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, string&gt; TicketType = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, string&gt; QueueNameById = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, string&gt; QueueIdByName = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, string&gt; AssignedResourceRole = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, string&gt; AssignedResource = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, string&gt; AllocationCode = new Dictionary&lt;string, string&gt;();
  public static Dictionary&lt;string, string&gt; ResourcesNameById = new Dictionary&lt;string, string&gt;();
  
  public static void Preload()
      {
  
          var client = new SoapClient().Admin();
          AutotaskIntegrations ati = new AutotaskIntegrations();
  
  
  
  
  
  
          Field[] fieldInfo = client.GetFieldInfo(ati, "Ticket");
  
          foreach (var item in fieldInfo)
          {
              if (item.IsPickList)
              {
                  foreach (var pValue in item.PicklistValues)
                  {
  
                      switch (item.Name)
                      {
  
                          case "Status":
                              StatusIdByName.Add(pValue.Label, pValue.Value);
                              StatusNameById.Add(pValue.Value, pValue.Label);
                              break;
                          case "IssueType":
                              IssueType.Add(pValue.Label, pValue.Value);
                              break;
                          case "SubIssueType":
                              SubIssueLabel.Add(pValue.Label, new Tuple&lt;string, string&gt;(pValue.parentValue, pValue.Value));
                              SubIssueValue.Add(new Tuple&lt;string, string&gt;(pValue.parentValue, pValue.Value), pValue.Label);
                              break;
                          case "Priority":
                              Priority.Add(pValue.Label, pValue.Value);
                              break;
                          case "Source":
                              Source.Add(pValue.Label, pValue.Value);
                              break;
                          case "ServiceLevelAgreementID":
                              ServiceLevelAgreement.Add(pValue.Label, pValue.Value);
                              break;
                          case "TicketType":
                              TicketType.Add(pValue.Label, pValue.Value);
                              break;
                          case "QueueID":
                              QueueNameById.Add(pValue.Value, pValue.Label);
                              QueueIdByName.Add(pValue.Label, pValue.Value);
                              break;
                          case "AllocationCodeID":
                              AllocationCode.Add(pValue.Label, pValue.Value);
                              break;
                          case "AssignedResourceID":
                              AssignedResource.Add(pValue.Label, pValue.Value);
                              break;
                          case "AssignedResourceRoleID":
                              AssignedResourceRole.Add(pValue.Label, pValue.Value);
                              break;
                      }
                  }
              }
          }
      }
  </code></pre>
  
  <p>Now, with most of the PickList -> Dictionaries I am able to simply specify the source as the dictionary. </p>
  
  <pre><code>private void FillCombos()
      {
          AutoTaskData.Preload();
          AutoTaskData.ResourcesIdByName.Add("", "clear");
          ResourceBox.ItemsSource = AutoTaskData.ResourcesIdByName;
          AutoTaskData.QueueIdByName.Add("", "clear");
          QueueBox.ItemsSource = AutoTaskData.QueueIdByName;
          AutoTaskData.StatusIdByName.Add("", "clear");
          StatusBox.ItemsSource = AutoTaskData.StatusIdByName;
      }
  </code></pre>
  
  <p>XAML:</p>
  
  <pre><code>&lt;ComboBox x:Name="QueueBox" SelectedValuePath="Value" DisplayMemberPath="Key" SelectionChanged="QueueBox_SelectionChanged"  /&gt;
  &lt;TextBlock Margin="5,10,10,0"&gt;Resource&lt;/TextBlock&gt;
  &lt;ComboBox x:Name="ResourceBox" SelectedValuePath="Value" DisplayMemberPath="Key" SelectionChanged="ResourceBox_SelectionChanged"  /&gt;
  &lt;TextBlock Margin="5,10,10,0"&gt;Status&lt;/TextBlock&gt;
  &lt;ComboBox x:Name="StatusBox" SelectedValuePath="Value" DisplayMemberPath="Key" /&gt;
  </code></pre>
  
  <p>This obviously doesn't work for the SubIssueType's though, as they are all in one dictionary and I only want values displayed if an IssueType is selected that matches their "pValue.ParentValue" variable (or in other words the first tuple of the dictionaries key or value). Perhaps tuples aren't the way to go, however I'm not sure what the best implementation would be for this.   </p>