Select to view content in your preferred language

Bind a TextBlock to the Map's Resolution

856
3
02-22-2011 08:49 AM
TedChapin
Frequent Contributor
Does anyone know why this:
<TextBlock Text="{Binding Resolution, ElementName=MapMain, Mode=OneWay}" ></TextBlock>

produces "NaN" instead of the map's resolution?  I tried the same thing with the map's Extent.Width property and it works fine.
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
I think you have it correctly if your map control is named "MapMain". However, v2.1 and earlier do not support Binding for "Resolution", this is new to v2.2

The following code will only work for v2.2 and up:
<TextBlock Text="{Binding ElementName=MyMap, Path=Resolution}" VerticalAlignment="Top" HorizontalAlignment="Center"/>


The following code will work for v2.1 and earlier:
<TextBlock x:Name="MyResolution" Text="0" VerticalAlignment="Top" HorizontalAlignment="Center"/>
private void MyMap_ExtentChanged(object sender, ExtentEventArgs e)
{
 double res = Convert.ToDouble(MyResolution.Text);
 if (res != (sender as Map).Resolution)
 {
  res = (sender as Map).Resolution;
  MyResolution.Text = res.ToString();
 }
}
0 Kudos
DavidLamb
Occasional Contributor
I think you have it correctly if your map control is named "MapMain". However, v2.1 and earlier do not support Binding for "Resolution", this is new to v2.2



Where is v2.2 available?

Thanks,
David
0 Kudos
JenniferNery
Esri Regular Contributor
When it becomes available, there should be a link from here: http://help.arcgis.com/en/webapi/silverlight/index.html
to beta community site: https://betacommunity.esri.com/home.html
0 Kudos