|
POST
|
If you have Expression Blend, you can get the template of ScaleBar, notice that one of its Template parts is ScaleBarValue. You can subscribe to its Loaded event and access its Text value on Map_ExtentChanged (see snippets below). XAML:
<Style x:Key="ScaleBarStyle" TargetType="esri:ScaleBar">
<Setter Property="FillColor1" Value="White"/>
<Setter Property="FillColor2" Value="Black"/>
<Setter Property="TextColor" Value="White"/>
<Setter Property="TargetWidth" Value="150.0"/>
<Setter Property="FontSize" Value="10.0"/>
<Setter Property="BarHeight" Value="10.0"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="esri:ScaleBar">
<StackPanel Orientation="Horizontal">
<Grid x:Name="ScaleBarBlock" Height="{TemplateBinding BarHeight}" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Rectangle Grid.Column="0" Fill="{TemplateBinding FillColor2}" Grid.Row="0"/>
<Rectangle Grid.Column="1" Fill="{TemplateBinding FillColor1}" Grid.Row="0"/>
<Rectangle Grid.Column="2" Fill="{TemplateBinding FillColor2}" Grid.Row="0"/>
<Rectangle Grid.Column="3" Fill="{TemplateBinding FillColor1}" Grid.Row="0"/>
<Rectangle Grid.Column="4" Fill="{TemplateBinding FillColor2}" Grid.Row="0"/>
<Rectangle Grid.Column="0" Fill="{TemplateBinding FillColor1}" Grid.Row="1"/>
<Rectangle Grid.Column="1" Fill="{TemplateBinding FillColor2}" Grid.Row="1"/>
<Rectangle Grid.Column="2" Fill="{TemplateBinding FillColor1}" Grid.Row="1"/>
<Rectangle Grid.Column="3" Fill="{TemplateBinding FillColor2}" Grid.Row="1"/>
<Rectangle Grid.Column="4" Fill="{TemplateBinding FillColor1}" Grid.Row="1"/>
</Grid>
<TextBlock x:Name="ScaleBarValue" Loaded="ScaleBarValue_Loaded" Foreground="{TemplateBinding TextColor}" VerticalAlignment="Center"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Code-behind:
TextBlock scaleBarValue;
private void ScaleBarValue_Loaded(object sender, RoutedEventArgs e)
{
scaleBarValue = sender as TextBlock;
}
private void MyMap_ExtentChanged(object sender, ESRI.ArcGIS.Client.ExtentEventArgs e)
{
//check for scaleBarValue.Text
}
... View more
10-17-2010
02:01 PM
|
0
|
0
|
1455
|
|
POST
|
You can test if you will get the same results if you made your request directly to the REST service as you would in your SL app, this way... 1. Download Fiddler from: http://www.fiddler2.com/fiddler2/version.asp, if you don't have it already. 2. Copy the query parameters from Fiddler's Inspectors WebForms section (as seen in the attached screenshot). 3. From your browser, go to: http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/areasAndLengths and use the same parameters retrieved from step 2.
... View more
10-16-2010
05:28 PM
|
0
|
0
|
3059
|
|
POST
|
If you want to define the Binding in XAML, I don't see another way to do so without defining an instance of your ViewModel under Resource. If your ViewModel object looked like this
public class MyViewModelObject : INotifyPropertyChanged
{
public MyViewModelObject()
{
Graphics = new GraphicCollection();
}
private GraphicCollection graphics;
public GraphicCollection Graphics
{
get { return graphics; }
set
{
if (graphics != value)
{
graphics = value;
OnPropertyChanged("Graphics");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string property)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
You might be expecting that when you set your UserControl's DataContext to an instance of your ViewModel in code-behind like this:
MyViewModelObject obj = new MyViewModelObject();
this.DataContext = obj;
the following XAML-code would just work:
<esri:GraphicsLayer ID="MyGraphicsLayer" Graphics="{Binding Graphics}">
Unfortunately, this is not the case. While your Map can inherit the DataContext of your UserControl, GraphicsLayer will not. GraphicsLayer, unlike Map or any other UIElement, does not have a DataContext and will therefore fail to resolve this type of Binding. If you wish to define the Binding in code-behind, these two are equivalent: XAML:
<Grid.Resources>
<local:MyViewModelObject x:Key="obj"/>
</Grid.Resources>
<!-- more code here -->
<esri:GraphicsLayer ID="MyGraphicsLayer" Graphics="{Binding Source={StaticResource obj}, Path=Graphics, Mode=TwoWay}" >
Code-behind:
MyViewModelObject obj = new MyViewModelObject();
GraphicsLayer layer = this.MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
System.Windows.Data.Binding binding = new System.Windows.Data.Binding("Graphics");
binding.Source = obj;
binding.Mode = System.Windows.Data.BindingMode.TwoWay;
System.Windows.Data.BindingOperations.SetBinding(layer, GraphicsLayer.GraphicsProperty, binding);
Either way will let you modify the elements in your Map's GraphicsLayer.
obj.Graphics.Add(new Graphic() { Geometry = new MapPoint(17, 15) });
... View more
10-16-2010
04:57 PM
|
1
|
0
|
735
|
|
POST
|
Have you looked at this? http://help.arcgis.com/en/webapi/silverlight/help/Overview_Bing.htm Also this might help you troubleshoot the issue regarding blank layers: http://blogs.esri.com/Dev/blogs/silverlightwpf/archive/2009/08/24/Troubleshooting-blank-layers.aspx
... View more
10-16-2010
10:29 AM
|
0
|
0
|
1703
|
|
POST
|
ZoomToResolution's first parameter is a double (resolution), not Geometry. You might be confusing it with ZoomTo? Are you zooming in or out? Adding ConstrainExtentBehavior restricts you from zooming out of the set ConstrainedExtent so zoom in should not at all be affected. I tried the following call to ZoomToResolution from MouseClick event: This works MyMap.ZoomToResolution(MyMap.Resolution/2, e.MapPoint); // zoom in while this line does not because zoom would cause the map extent to go beyond the ConstrainedExtent. MyMap.ZoomToResolution(MyMap.Resolution/0.5, e.MapPoint); // zoom out
... View more
10-16-2010
10:03 AM
|
0
|
0
|
598
|
|
POST
|
The ScaleBar value gets updated when map extent changes so you can subscribe to your map's ExtentChanged event.
... View more
10-16-2010
09:31 AM
|
0
|
0
|
1455
|
|
POST
|
I'm afraid the symbols used in MeasureAction is not customizable. However, others have found a way to copy the graphics created by MeasureAction onto their map. You can refer to this forum: http://forums.arcgis.com/threads/13902-about-after-using-measure-behavior-the-graph-can-t-stay-in-the-map Maybe you can use the same approach and replace the TextSymbol with your own by checking the type of Symbol.
... View more
10-16-2010
09:15 AM
|
0
|
0
|
582
|
|
POST
|
I also am not able to reproduce the issue with the following code:
<Grid x:Name="LayoutRoot" Background="White">
<Grid.Resources>
<esri:Editor x:Key="MyEditor" Map="{Binding ElementName=MyMap}"/>
</Grid.Resources>
<esri:Map x:Name="MyMap" Extent="-85.9444646373356,37.9972855862017,-85.4429082072966,38.3780113173182">
<esri:ArcGISTiledMapServiceLayer ID="BaseLayer"
Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
<esri:FeatureLayer ID="Layer10" Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/MapServer/2"/>
<esri:FeatureLayer ID="Layer931" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Louisville/LOJIC_LandRecords_Louisville/MapServer/0"/>
</esri:Map>
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Center" DataContext="{StaticResource MyEditor}">
<Button x:Name="SelectBtn" Content="Select" Command="{Binding Select}"/>
<Button x:Name="ClearBtn" Content="Clear" Command="{Binding ClearSelection}"/>
</StackPanel>
</Grid>
Do you set ID on both layers? If not, maybe this is the reason the FeatureLayer is ignored. Please let me know what I did different to help me reproduce what you are experiencing with ClearSelection. Thanks!
... View more
10-16-2010
09:04 AM
|
0
|
0
|
1071
|
|
POST
|
You need to set OutFields. FeatureDataGrid need to know which fields need to be displayed and that is controlled by the layer's OutFields.
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
FeatureLayer layer = new FeatureLayer()
{
Url = "http://serverapps.esri.com/ArcGIS/rest/services/California/MapServer/8"
};
layer.OutFields.Add("*");
MyMap.Layers.Add(layer);
MyDataGrid.Map = MyMap;
MyDataGrid.GraphicsLayer = layer;
}
... View more
10-14-2010
07:28 AM
|
0
|
0
|
489
|
|
POST
|
You can use MouseLeftButtonDown on the map and get the MapPoint this way:
void MyMap_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Point screenPoint = e.GetPosition(MyMap);
MapPoint mapPoint = MyMap.ScreenToMap(screenPoint);
}
You can also use VertexAdded on the draw object and get the MapPoint this way:
void MyDrawObject_VertexAdded(object sender, VertexAddedEventArgs e)
{
MapPoint mapPoint = e.Vertex;
}
MouseClick is not raised when Draw is enabled is by design.
... View more
10-14-2010
07:07 AM
|
0
|
0
|
732
|
|
POST
|
If you choose to set Image Source the same way as the sample: "Assets/images/i_zoomout.png", you need to have Assets folder created from VisualStudio. Right-click on the project to Add > New Folder and name it "Assets", and then create "images" sub-folder by right-clicking on "Assets" folder, you should then have your PNG files added here by right-clicking on "images" (Add > Existing Item). If doing this still does not work, try changing Image Source to "/YourAssemblyName;component/Assets/images/i_zoomout.png" If you need to stick to VS2008, then you can use ArcGIS API for SL/WPF v1.2.
... View more
10-14-2010
06:56 AM
|
0
|
0
|
1378
|
|
POST
|
You can go to this link to see what's new with 2.1 http://help.arcgis.com/en/webapi/silverlight/2.1/help/index.html?Whats_New.htm
... View more
10-13-2010
12:50 PM
|
0
|
0
|
1762
|
|
POST
|
How about if you iterate through Map.Layers property? Something like
foreach(var layer in MainPageMap.Layers)
{
if(layer is ArcGISTiledMapServiceLayer)
{
ArcGISTiledMapServiceLayer tiledLayer = layer as ArcGISTiledMapServiceLayer;
//TODO: Set all properties you need to copy
ChildWindowMap.Layers.Add(new ArcGISTiledMapServiceLayer() {Url = tiledLayer.Url}); }
}
//TODO: continue to check other layer types
}
... View more
10-13-2010
12:25 PM
|
0
|
0
|
705
|
|
POST
|
You need to add that assembly. Right-click on your Project's References "Add Reference..", one of the .NET assemblies is called "System.Runtime.Serialization", add that to your project.
... View more
10-13-2010
11:48 AM
|
0
|
0
|
604
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-11-2025 01:30 PM | |
| 1 | 06-06-2025 10:14 AM | |
| 1 | 03-17-2025 09:47 AM | |
| 1 | 07-24-2024 07:32 AM | |
| 1 | 04-05-2024 06:37 AM |
| Online Status |
Offline
|
| Date Last Visited |
03-12-2026
09:38 AM
|