Using PointDataSource Online

This sample demonstrates how to create a graphics layer by binding to a source of items that reference location using X and Y values. The PointDataSource property references an ObservableCollection of objects with properties containing X and Y values. The PointDataSource.XCoordinateBinding is set to the property containing X values, and the PointDataSource.YCoordinateBinding is set to the property containing Y values. The appropriate event mechanisms are in place so changes in the items are reflected in the graphics layer. This sample highlights how the functionality can be used in the Model View ViewModel (MVVM) design pattern.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.UsingPointDataSource"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
    xmlns:local="clr-namespace:ArcGISWPFSDK">

    <UserControl.Resources>
        <local:MainViewModel x:Key="MyViewModel" />
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">

        <Grid.Resources>
            <esri:PictureMarkerSymbol x:Key="SelectMarkerSymbol" Source="http://static.arcgis.com/images/Symbols/Basic/YellowFlag.png" 
                  Width="24" Height="24" OffsetX="12" OffsetY="12"/>
        </Grid.Resources>

        <esri:Map x:Name="MyMap" UseAcceleratedDisplay="True" WrapAround="True" >

            <esri:ArcGISTiledMapServiceLayer ID="BaseMap"
				Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />

            <esri:GraphicsLayer>
                <esri:GraphicsLayer.GraphicsSource>
                    <esri:PointDataSource
                            ItemsSource="{Binding Source={StaticResource MyViewModel}, 
                            Path=Instance.Data.PointsOfInterest}"
                            XCoordinateBinding="{Binding X}"
                            YCoordinateBinding="{Binding Y}"
                            IsSelectedBinding="{Binding IsSelected}">
                    </esri:PointDataSource>
                </esri:GraphicsLayer.GraphicsSource>

                <esri:GraphicsLayer.Renderer>
                    <esri:SimpleRenderer Symbol="{StaticResource SelectMarkerSymbol}" />
                </esri:GraphicsLayer.Renderer>

                <esri:GraphicsLayer.MapTip>
                    <Grid DataContext="{Binding [DataContext]}" Background="White" esri:GraphicsLayer.MapTipAutoPosition="True">
                        <StackPanel Orientation="Vertical" Margin="5" >
                            <TextBlock Text="{Binding Name}"  />
                        </StackPanel>
                        <Border BorderBrush="Black" BorderThickness="1" />
                    </Grid>
                </esri:GraphicsLayer.MapTip>
            </esri:GraphicsLayer>

        </esri:Map>

        <Border HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10" Padding="5" Background="White" 
                BorderBrush="Black" BorderThickness="1">
            <Border.Effect>
                <DropShadowEffect />
            </Border.Effect>
            <StackPanel DataContext="{Binding Source={StaticResource MyViewModel}, Path=Instance}"
                    Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Left" 
                    Width="330" Height="50" Margin="5">
                <Button Content="Add item" Command="{Binding AddRandom}" Margin="5" Width="100" />
                <Button Content="Remove item" Command="{Binding RemoveFirst}" Margin="5" Width="100"/>
                <Button Content="Randomize items" Command="{Binding Randomize}" Margin="5" Width="100"/>
            </StackPanel>
        </Border>
    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014