I use attribute query sample its work but the problem is that in my XML have this codes
<esri:Map x:Name="MyMap" WrapAround="True" Extent="-15000000,2000000,-7000000,8000000">
<esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"
Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
<esri:GraphicsLayer ID="MyGraphicsLayer" />
</esri:Map>
but i want to bind this map from my Main Map Page
How i Resolve this problem
I use another User Control
Thanks in advance
Jennifer NeryArcGIS API for Silverlight@
Solved! Go to Solution.
As Dominique mentioned we have several toolkit samples that do this. It might be best to see them in action during debug so you can better understand how the map is passed to the controls.
So if you have a different UserControl for your attribute query (i.e. AttributeQueryControl), you will need to define a Map as DependencyProperty like this:
// Map to print (Dependency Property) public ESRI.ArcGIS.Client.Map Map { get { return (ESRI.ArcGIS.Client.Map)GetValue(MapProperty); } set { SetValue(MapProperty, value); } } public static readonly DependencyProperty MapProperty = DependencyProperty.Register("Map", typeof(ESRI.ArcGIS.Client.Map), typeof(AttributeQueryControl), new PropertyMetadata(null, OnMapChanged)); private static void OnMapChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var control = d as AttributeQueryControl; var newMap = e.NewValue as ESRI.ArcGIS.Client.Map; // Do what you need to do with the map here. }
Which you can then later you use like this:
<esri:Map x:Name="MyMap" WrapAround="True" Extent="-15000000,2000000,-7000000,8000000"> <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/> <esri:GraphicsLayer ID="MyGraphicsLayer" /> </esri:Map> <local:AttributeQueryControl x:Name="MyControl" Map="{Binding ElementName=MyMap}" VerticalAlignment="Center" HorizontalAlingment="Center"/>
I don't know where is exactly your problem but there is lot of samples in the interactive SDK that binds the map to a control. See for example the MapProgressBar.
If you want to look at the code of the control itself, it's available on github.
Dear Sir , i use Attribute Query Sample ,
my problem is i use this script on another form, script is loading but loading the map on current form, i have also main map page where all controls ,
i want this script work my main map page not in this form
Thanks
As Dominique mentioned we have several toolkit samples that do this. It might be best to see them in action during debug so you can better understand how the map is passed to the controls.
So if you have a different UserControl for your attribute query (i.e. AttributeQueryControl), you will need to define a Map as DependencyProperty like this:
// Map to print (Dependency Property) public ESRI.ArcGIS.Client.Map Map { get { return (ESRI.ArcGIS.Client.Map)GetValue(MapProperty); } set { SetValue(MapProperty, value); } } public static readonly DependencyProperty MapProperty = DependencyProperty.Register("Map", typeof(ESRI.ArcGIS.Client.Map), typeof(AttributeQueryControl), new PropertyMetadata(null, OnMapChanged)); private static void OnMapChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var control = d as AttributeQueryControl; var newMap = e.NewValue as ESRI.ArcGIS.Client.Map; // Do what you need to do with the map here. }
Which you can then later you use like this:
<esri:Map x:Name="MyMap" WrapAround="True" Extent="-15000000,2000000,-7000000,8000000"> <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/> <esri:GraphicsLayer ID="MyGraphicsLayer" /> </esri:Map> <local:AttributeQueryControl x:Name="MyControl" Map="{Binding ElementName=MyMap}" VerticalAlignment="Center" HorizontalAlingment="Center"/>
i understand Now , This Method Have some Assembly Problems ,
Actually my Boss Want 2 Query tools 1 is combox and 1 is select layer from combo and then search with textbox and button,
I use another user control , so i want bind my main map , if u provide me this 2 tools samples from another user Control, i will understand it Better , i like ur teaching style and want learn something from you
Regards
Ok well , i am asking 1 thing more ,How define namespace for this?