Back to Devexpress

BingSearchCompletedEventArgs Class

wpf-devexpress-dot-xpf-dot-map-04616fc7.md

latest7.9 KB
Original Source

BingSearchCompletedEventArgs Class

OBSOLETE

This class is obsolete. Microsoft deprecated Bing Maps on June 30th, 2025. For alternative providers, see https://www.devexpress.com/bing-maps-wpf

Provides data for the BingSearchDataProvider.SearchCompleted event.

Namespace : DevExpress.Xpf.Map

Assembly : DevExpress.Xpf.Map.v25.2.dll

NuGet Package : DevExpress.Wpf.Map

Declaration

csharp
[Obsolete("This class is obsolete. Microsoft deprecated Bing Maps on June 30th, 2025. For alternative providers, see https://www.devexpress.com/bing-maps-wpf")]
[PreferableMember("BingSearchCompletedEventArgs", "", "")]
public class BingSearchCompletedEventArgs :
    SearchCompletedEventArgs
vb
<Obsolete("This class is obsolete. Microsoft deprecated Bing Maps on June 30th, 2025. For alternative providers, see https://www.devexpress.com/bing-maps-wpf")>
<PreferableMember("BingSearchCompletedEventArgs", "", "")>
Public Class BingSearchCompletedEventArgs
    Inherits SearchCompletedEventArgs

BingSearchCompletedEventArgs is the data class for the following events:

Remarks

An instance of the BingSearchCompletedEventArgs class with appropriate settings is automatically created and passed to the corresponding event’s handler.

Example

This example demonstrates how to manually process received Bing Search request results.

Important

On May 21, 2024, Microsoft announced that Bing Maps for Enterprise and its API will be discontinued. Azure Maps will be a single unified enterprise mapping platform available from Microsoft.

To obtain and display map data from Azure Maps, we implemented the following providers:

For information on how to migrate your app from Bing Maps to Azure Maps, see the following help topic: DevExpress Map Control for WPF: Migrate from Bing Maps to Azure Maps.

If you already have a Bing Maps for Enterprise license, you can keep using the current API. You must transition to the new API by June 30, 2025 (for free/basic licenses) or June 30, 2028 (for enterprise licenses). New licenses will no longer be available after June 30, 2025. Bing Maps will not work with our map controls without a license after that date.

View Example

vb
Private Sub searchProvider_SearchCompleted(ByVal sender As Object, ByVal e As BingSearchCompletedEventArgs)
    If e.Cancelled Then
        Return
    End If
    If e.RequestResult.ResultCode <> RequestResultCode.Success Then
        Return
    End If

    Dim sb As New StringBuilder()

    Dim requestResult As SearchRequestResult = e.RequestResult
    sb.Append(String.Format("Result Code: {0}" & vbLf, requestResult.ResultCode))
    If String.IsNullOrEmpty(requestResult.FaultReason) Then
        sb.Append(String.Format("Fault Reason: (none)" & vbLf, requestResult.FaultReason))
    Else
        sb.Append(String.Format("Fault Reason: {0}" & vbLf, requestResult.FaultReason))
    End If
    sb.Append(String.Format("Search Location: {0}" & vbLf, requestResult.Keyword))
    sb.Append(String.Format("Estimated Matches: {0}" & vbLf, requestResult.EstimatedMatches))
    sb.Append(String.Format("SearchResults:" & vbLf & "{0}", ProcessLocationList(requestResult.SearchResults)))

    tbSearchResult.Text = sb.ToString()

End Sub

Private Function ProcessLocationList(ByVal results As List(Of LocationInformation)) As String
    If results Is Nothing Then
        Return ""
    End If

    Dim sb As New StringBuilder()
    For i As Integer = 0 To results.Count - 1
        sb.Append(String.Format("{0}) {1}", i + 1, ProcessLocationInformation(results(i))))
    Next i
    Return sb.ToString()
End Function
Private Function ProcessLocationInformation(ByVal info As LocationInformation) As String
    If info Is Nothing Then
        Return ""
    End If

    Dim sb As New StringBuilder()

    sb.Append(String.Format("{0}" & vbLf, info.DisplayName))
    sb.Append(String.Format(vbTab & "Adress: {0}" & vbLf, info.Address))
    sb.Append(String.Format(vbTab & "Location: {0}" & vbLf, info.Location))
    Return sb.ToString()
End Function
csharp
private void searchProvider_SearchCompleted(object sender, BingSearchCompletedEventArgs e) {
    if (e.Cancelled) return;
    if (e.RequestResult.ResultCode != RequestResultCode.Success) return;

    StringBuilder sb = new StringBuilder();

    SearchRequestResult requestResult = e.RequestResult;
    sb.Append(String.Format("Result Code: {0}\n", requestResult.ResultCode));
    if (String.IsNullOrEmpty(requestResult.FaultReason))
        sb.Append(String.Format("Fault Reason: (none)\n", requestResult.FaultReason));
    else
        sb.Append(String.Format("Fault Reason: {0}\n", requestResult.FaultReason));
    sb.Append(String.Format("Search Location: {0}\n", requestResult.Keyword));
    sb.Append(String.Format("Estimated Matches: {0}\n", requestResult.EstimatedMatches));
    sb.Append(String.Format("SearchResults:\n{0}", ProcessLocationList(requestResult.SearchResults)));

    tbSearchResult.Text = sb.ToString();

}

string ProcessLocationList(List<LocationInformation> results) {
    if (results == null) return "";

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < results.Count; i++) {
        sb.Append(String.Format("{0}) {1}", i + 1, ProcessLocationInformation(results[i])));
    }
    return sb.ToString();
}
string ProcessLocationInformation(LocationInformation info) {
    if (info == null) return "";

    StringBuilder sb = new StringBuilder();

    sb.Append(String.Format("{0}\n", info.DisplayName));
    sb.Append(String.Format("\tAdress: {0}\n", info.Address));
    sb.Append(String.Format("\tLocation: {0}\n", info.Location));
    return sb.ToString();
}

Inheritance

Object EventArgs AsyncCompletedEventArgs SearchCompletedEventArgs BingSearchCompletedEventArgs

See Also

BingSearchCompletedEventArgs Members

DevExpress.Xpf.Map Namespace