Select to view content in your preferred language

Reg : Combobox Items

538
1
10-03-2010 02:38 PM
VikramS
Frequent Contributor
HI all ,

I am trying to bind the combobox with the Tract names . But my combobox items are loaded with ESRI.ArcGIS.Client.Tasks.FindResult . Can anyone let me know what i need to do to get the TractNAme alone from the Find task
Xaml:

<ComboBox x:Name="combo" Width="200" ItemsSource="{Binding Tract}"
Code Behind:

Dim findTask As New FindTask("http://epps65335.campus.ad.utdallas.edu/ArcGIS/rest/services/CrimeAnalysis/MapServer")
            AddHandler findTask.Failed, AddressOf FindTask_Failed

            Dim findParameters As New FindParameters()
            ' Layer ids to search
            findParameters.SearchText = txtfind.Text.Trim
            findParameters.Contains = True
            findParameters.LayerIds.AddRange(New Integer() {13, 15})
            ' Fields in layers to search
            findParameters.SearchFields.AddRange(New String() {"TRACT", "COUNTY"})

            Dim resultFeaturesBinding As New Binding("LastResult")
            resultFeaturesBinding.Source = findTask
    combo.SetBinding(ComboBox.ItemsSourceProperty, resultFeaturesBinding)
            findTask.ExecuteAsync(findParameters)
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
You don't need to set ItemSouce in XAML anymore, if you are already creating the binding in code-behind. This should be enough to set the ItemSource.
combo.SetBinding(ComboBox.ItemsSourceProperty, resultFeaturesBinding)


However, you need to define the ItemTemplate for your combobox. Note that this is case-sensitive and should match the field you are binding to.
 <ComboBox x:Name="combo" Width="200">
   <ComboBox.ItemTemplate>
    <DataTemplate>
     <TextBlock Text="{Binding TRACT}"/>
    </DataTemplate>
   </ComboBox.ItemTemplate>
  </ComboBox>
0 Kudos