Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

BingTrafficIncidentCalculatedEventArgs Class

Provides data for the TrafficIncidentCalculated event.

Namespace: DevExpress.Xpf.Map

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

NuGet Package: DevExpress.Wpf.Map

#Declaration

public class BingTrafficIncidentCalculatedEventArgs :
    AsyncCompletedEventArgs

#Example

#How to: Obtain and Display a List of Traffic Incidents

This example obtains a list of incidents in the specified area from the Bing Maps service and displays information about obtained incidents in a TextEdit control.

A map with a list of incidents.

<Window xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TrafficIncidents"
        xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map" 
        x:Class="TrafficIncidents.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800" Loaded="OnWindowLoaded">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="5*"/>
            <ColumnDefinition Width="2*"/>
        </Grid.ColumnDefinitions>    
            <dxm:MapControl x:Name="mapControl" Grid.Column="0">
                <dxm:ImageLayer>
                    <dxm:BingMapDataProvider BingKey="Insert your Bing key." 
                                             Kind="RoadLight"/>
                </dxm:ImageLayer>
                <dxm:InformationLayer DataRequestCompleted="OnDataRequestCompleted">
                    <dxm:BingTrafficIncidentDataProvider x:Name="incidentProvider" 
                                                         BingKey="Insert your Bing key." 
                                                         TrafficIncidentCalculated="OnTrafficIncidentCalculated" />
                </dxm:InformationLayer>
            </dxm:MapControl>
            <dxe:TextEdit x:Name="textEdit" TextWrapping="Wrap" Grid.Column="1"/>
    </Grid>
</Window>
using DevExpress.Xpf.Map;
using System.Text;
using System.Windows;

namespace TrafficIncidents {
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }
        private void OnWindowLoaded(object sender, RoutedEventArgs e) {
            BingTrafficIncidentSeverity incidentSeverity = BingTrafficIncidentSeverity.LowImpact | BingTrafficIncidentSeverity.Minor | 
                                                                BingTrafficIncidentSeverity.Moderate | BingTrafficIncidentSeverity.Serious;
            BingTrafficIncidentType incidentType = BingTrafficIncidentType.Accident | BingTrafficIncidentType.Construction | 
                                                        BingTrafficIncidentType.Miscellaneous | BingTrafficIncidentType.Weather;
            SearchBoundingBox searchArea = new SearchBoundingBox { WestLongitude = -115.338457, NorthLatitude = 36.268745, 
                                                                    EastLongitude = -114.988268, SouthLatitude= 36.1010376 };
            incidentProvider.RequestTrafficIncidents( searchArea, incidentSeverity, incidentType);
        }
        private void OnDataRequestCompleted(object sender, RequestCompletedEventArgs e) {
            // Zoom the map so that it displays the obtained incidents.
            mapControl.ZoomToFitLayerItems();
        }
        private void OnTrafficIncidentCalculated(object sender, BingTrafficIncidentCalculatedEventArgs e) {
            if (e.Cancelled) return;
            if (e.RequestResult.ResultCode != RequestResultCode.Success) {
                textEdit.Text = "Traffic incidents were not found for this area.";
                return;
            }
            StringBuilder resultList = new StringBuilder("");
            int resCounter = 1;
            foreach (BingTrafficIncidentResult resultInfo in e.RequestResult.IncidentResults) {
                resultList.Append(string.Format("Incident {0}: \r\n", resCounter));
                resultList.Append(string.Format("Type: {0}\r\n", resultInfo.Type));
                resultList.Append(string.Format("Description: {0}\r\n", resultInfo.Description));
                resultList.Append(string.Format("Start Time: {0}\r\n", resultInfo.StartTime));
                resultList.Append(string.Format("End Time: {0}\r\n", resultInfo.EndTime));
                resultList.Append(string.Format("Lat: {0}, Lon: {1}\r\n", resultInfo.Point.Latitude, resultInfo.Point.Longitude));
                resultList.Append(string.Format("______________________________\r\n"));
                resCounter++;
            }
            textEdit.Text = resultList.ToString();
        }
    }
}

#Inheritance

Object
EventArgs
AsyncCompletedEventArgs
BingTrafficIncidentCalculatedEventArgs
See Also