Is there a way to reorder the layers in a project? I have a district layer that is loaded at the start and a county layer that is loaded only when a district is clicked. I would like to be able to see just the counties that appear under that district. Is it possible to do this without having to create a separate shapefile for each county?
If you were to have some attributes in the shapefile that could identify which district elements belonged to, you could filter out any elements you did not want to see when the file is imported, or toggle visibility flags, potentially. Does that help?
Sort of. Can you give a quick example in vb or c#?
Thanks Graham. I ended up going in a different direction but that info is very helpful and will probably be used in a different project.
Maybe you've figured it out, but there are all sorts of things you can do with the element properties to help you partition items in a layer. And the element properties can be specified by you or come from your shapefile. Here's an example:
public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void statesLayer_Imported( object sender, Infragistics.Silverlight.Map.MapLayerImportEventArgs e) { foreach (MapElement ele in (sender as MapLayer).Elements) { if (ele.Caption[0] < 'M') { ele.SetProperty("Special", true); } else { ele.SetProperty("Special", false); } } } private void theMap_ElementClick( object sender, MapElementClickEventArgs e) { if ((bool)e.Element.GetProperty("Special")) { foreach (MapElement ele in (sender as XamWebMap).Layers[0].Elements) { if ((bool)ele.GetProperty("Special")) { ele.Fill = new SolidColorBrush(Colors.Red); } else { ele.Fill = new SolidColorBrush(Colors.Blue); } } } else { foreach (MapElement ele in (sender as XamWebMap).Layers[0].Elements) { if (!(bool)ele.GetProperty("Special")) { ele.Fill = new SolidColorBrush(Colors.Red); } else { ele.Fill = new SolidColorBrush(Colors.Blue); } } } } }
-Graham