Below is my attempt at creating the Address Location Tool Alternative. (I am very new to programming) I currently have 3 errors:1. "The name 'InitializeComponent' does not exist in the current context"2. "ESRI.ArcGIS.Client.Tasks.Address' does not contain a definition for 'Text'3. The name 'LayoutRoot' does not exist in the current context"If someone wouldn't mind taking a look and making suggestions to make this work, I would greatly appreciate it. There is 1 xaml file and 2 cs files:AddressLocationTool.xaml:<UserControl x:Class="AddressLocationTool.AddIns.MyConfigDialog"
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:esri="http://schemas.esri.com/arcgis/client/2009"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:slData="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:extensibility="clr-namespace:ESRI.ArcGIS.Client.Extensibility;assembly=ESRI.ArcGIS.Client.Extensibility">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.Resources>
<esri:PictureMarkerSymbol x:Key="AddressToLocationSymbol"
OffsetX="0"
OffsetY="31"
Source="C:\TOwens\Viewer_Apps\AddressLocationTool\AddressLocationTool\AddressLocationTool\Images\MarkerSymbols\Basic\BlueStickpin.png" />
</Grid.Resources>
<!-- LOCATOR TASK INTERFACE -->
<StackPanel Margin="10" HorizontalAlignment="Left">
<Grid>
<Rectangle Fill="#CC5C90B2"
Stroke="Gray"
RadiusX="10"
RadiusY="10" />
<StackPanel Margin="10" HorizontalAlignment="Center" >
<TextBlock Text="Click Find to locate an address"
HorizontalAlignment="Center"
Margin="0,0,0,5"
Foreground="White"
FontStyle="Italic" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
<TextBlock Text="Address: " Foreground="White" />
<TextBox x:Name="Address" Text="177 N Church Ave" Width="125" />
</StackPanel>
<Button x:Name="FindAddressButton"
Content="Find" Width="100"
HorizontalAlignment="Center"
Click="FindAddressButton_Click"
Margin="0,5,0,0" />
<Line HorizontalAlignment="Center" X1="0" Y1="10" X2="180" Y2="10" StrokeThickness="1" Stroke="White" />
</StackPanel>
</Grid>
</StackPanel>
</Grid>
</UserControl>
AddressLocationTool.xaml.cs:using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Interactivity;
using System.ComponentModel.Composition;
using System.ComponentModel;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Extensibility;
using ESRI.ArcGIS.Client.Tasks;
using ESRI.ArcGIS.Client.Symbols;
using ESRI.ArcGIS.Client.Geometry;
using System.Collections.Generic;
namespace AddressLocationTool.AddIns
{
public partial class AddressLocationTool : UserControl
{
public AddressLocationTool()
{
InitializeComponent();
}
// Find the location of an address when the Find button is clicked.
private void FindAddressButton_Click(object sender, RoutedEventArgs e)
{
// Initialize the Locator.
Locator locatorTask = new Locator("GeocodeServer web address" +
"Locators/ESRI_Geocode_USA/GeocodeServer");
locatorTask.AddressToLocationsCompleted += LocatorTask_AddressToLocationsCompleted;
locatorTask.Failed += LocatorTask_Failed;
// Initialize the address.
AddressToLocationsParameters addressParameters = new AddressToLocationsParameters();
Dictionary<string, string> address = addressParameters.Address;
address.Add("Address", Address.Text);
// Call method to locate the address.
locatorTask.AddressToLocationsAsync(addressParameters);
}
// When the address has been located, show the best match on the map.
private void LocatorTask_AddressToLocationsCompleted(object sender, ESRI.ArcGIS.Client.Tasks.AddressToLocationsEventArgs args)
{
// Check whether results were found.
if (args.Results.Count > 0)
{
// Get the best match.
AddressCandidate bestCandidate = args.Results[0];
foreach (AddressCandidate candidate in args.Results)
bestCandidate = (candidate.Score > bestCandidate.Score) ? candidate : bestCandidate;
// Create a graphic for the match.
Graphic graphic = new Graphic()
{
Symbol = LayoutRoot.Resources["AddressToLocationSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
Geometry = bestCandidate.Location
};
// Add the address and coordinates to the graphic.
graphic.Attributes.Add("Address", bestCandidate.Address);
string latLon = String.Format("{0}, {1}", bestCandidate.Location.X, bestCandidate.Location.Y);
graphic.Attributes.Add("LatLon", latLon);
// Show the graphic by adding it to a graphics layer.
GraphicsLayer graphicsLayer = MapApplication.Current.Map.Layers["AddressToLocationGraphicsLayer"] as GraphicsLayer;
graphicsLayer.ClearGraphics();
graphicsLayer.Graphics.Add(graphic);
}
else
{
// Notify user.
MessageBox.Show("No results found");
}
}
// Notify the user if the task fails to execute.
private void LocatorTask_Failed(object sender, TaskFailedEventArgs e)
{
MessageBox.Show("Locator service failed: " + e.Error);
}
}
}
AddressTool.cs:using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Interactivity;
using System.ComponentModel.Composition;
using System.ComponentModel;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Extensibility;
namespace AddressLocationTool.AddIns
{
[Export(typeof(ICommand))]
[DisplayName("Address Location")]
public class AddressTool : ICommand
{
private AddressLocationTool addressUI;
public AddressTool()
{
addressUI = new AddressLocationTool();
}
public void Execute(object parameter)
{
MapApplication.Current.ShowWindow("Address Location", addressUI);
}
public bool CanExecute(object parameter)
{
// Return true so that the command can always be executed
return true;
}
public event EventHandler CanExecuteChanged;
}
}
Thanks in advance for any help.