<Popup x:Name="locationResultsPopUp" IsOpen="True" HorizontalAlignment="Left" VerticalAlignment="Top"> <ListBox x:Name="locationResults" Background="White" SizeChanged="locationResults_SizeChanged" SelectionChanged="locationResults_SelectionChanged" Visibility="Collapsed" LostFocus="locationResults_LostFocus"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Foreground="#002969" FontSize="9" Text="{Binding [Descr]}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Popup>
Difficult to answer without seeing your code.I guess the ItemsSource is initialized by code. It should be initialized to a collection of Dictionary.From your description it looks like it's well initialized to a collection (because you see the correct number of item). But either the item is not a dictionary or the key "Descr" is not existing in the dictionary.
Private Sub LocatorTask_AddressToLocationsCompleted(ByVal sender As Object, ByVal args As AddressToLocationsEventArgs) Dim FullList As List(Of AddressCandidate) = args.Results Dim returnedCandidates As New List(Of AddressCandidate) For Each AddressCandidate As AddressCandidate In FullList If (AddressCandidate.Attributes("State") = "Louisiana" Or AddressCandidate.Attributes("State") = "Texas") Then returnedCandidates.Add(AddressCandidate) End If Next If returnedCandidates.Count = 1 Then Dim best As AddressCandidate = returnedCandidates(0) Dim env As New Envelope() With {.XMin = Double.Parse(best.Attributes("West_Lon").ToString(), CultureInfo.InvariantCulture), _ .YMin = Double.Parse(best.Attributes("South_Lat").ToString(), CultureInfo.InvariantCulture), _ .XMax = Double.Parse(best.Attributes("East_Lon").ToString(), CultureInfo.InvariantCulture), _ .YMax = Double.Parse(best.Attributes("North_Lat").ToString(), CultureInfo.InvariantCulture)} Dim MyDescr As String = best.Attributes("Descr").ToString.Replace(", United States", "") locationTextBox.Text = MyDescr env = env.GeographicEnvToWebMercatorEnv 'Extension Method Map.ZoomTo(env) ElseIf returnedCandidates.Count > 1 Then locationResults.Visibility = Visibility.Visible locationResults.ItemsSource = returnedCandidates Else locationTextBox.Text = "Location Not Found (LA/TX)" End If End Sub
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.