Here is a simple sample that you can use to test your service. You can replace the services in this sample with yours to test that it is working correctly. basically this sample will load up a base map and a feature layer with some points on the screen. when you click the button in the top left of the screen it will grab your current extent of the map and create a polygon out of it. the polygon is then used in a query task to query the same feature layer service you see on the map. When the quey task comepletes it will give you a count of how many items it found on the screen. so the count should be the same as the number items you see on your map.XAML
<Grid x:Name="LayoutRoot" Background="White">
<esri:Map x:Name="esriMap">
<esri:Map.Layers>
<esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
<esri:FeatureLayer Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/LandusePlanning/MapServer/0" />
</esri:Map.Layers>
</esri:Map>
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" >
<Button Content="Query Polygon" Click="Button_Click" />
<Button Content="Query Envelope" Click="Button_Click_1" />
</StackPanel>
</Grid>
CodeBehind
public partial class MainPage : UserControl
{
Query query;
QueryTask rTask;
public MainPage()
{
InitializeComponent();
rTask = new QueryTask("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/LandusePlanning/MapServer/0");
rTask.ExecuteCompleted += new EventHandler<QueryEventArgs>(rTask_ExecuteCompleted);
rTask.Failed += new EventHandler<TaskFailedEventArgs>(rTask_Failed);
query = new ESRI.ArcGIS.Client.Tasks.Query();
// Specify fields to return from query
query.OutFields.Add("*");
query.ReturnGeometry = true;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
// Create a polygon of your current extent. Should returns the number
// of items you see on your screen.
query.Geometry = CreatePolygonFromMapExtent();
rTask.ExecuteAsync(query);
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
query.Geometry = esriMap.Extent;
rTask.ExecuteAsync(query);
}
void rTask_ExecuteCompleted(object sender, QueryEventArgs e)
{
MessageBox.Show(string.Format("{0} features on screen.",e.FeatureSet.Features.Count));
}
Polygon CreatePolygonFromMapExtent()
{
Envelope extent = esriMap.Extent;
// Create a polygon of your current map extent
PointCollection pc = new PointCollection();
pc.Add(new MapPoint() { X = extent.XMin, Y = extent.YMax, SpatialReference = esriMap.SpatialReference }); // top left of map screen
pc.Add(new MapPoint() { X = extent.XMax, Y = extent.YMax, SpatialReference = esriMap.SpatialReference }); // top right of map screen
pc.Add(new MapPoint() { X = extent.XMax, Y = extent.YMin, SpatialReference = esriMap.SpatialReference }); // bottom right of map screen
pc.Add(new MapPoint() { X = extent.XMin, Y = extent.YMin, SpatialReference = esriMap.SpatialReference }); // bottom left of map screen
pc.Add(new MapPoint() { X = extent.XMin, Y = extent.YMax, SpatialReference = esriMap.SpatialReference }); // top left of map screen to close polygon
Polygon polygon = new Polygon() { SpatialReference = esriMap.SpatialReference };
polygon.Rings.Add(pc);
return polygon;
}
void rTask_Failed(object sender, TaskFailedEventArgs e)
{
MessageBox.Show(e.Error.Message);
}
}