Hi,
I added xamMap to my application and I set colors for map elements in my code behind on Loaded event depending on some character values. I would like to have a legend of my map which shows those character values. As far as understand, I have to use ValueScale with Distribution Scale. But I don't know where I should add a converter. Do you have any sample ?
Thanks,
Ed
Hello Ed,
Thank you for your post. I have been looking into your requirement and I am attaching a sample application(xamMapLegend.zip) where I show how to create a legend for your XamMap control.
If you need any further assistance on this matter, feel free to ask.
Yanko,
Thanks for the sample, but it's not what I would like to display. I would like, for example, set a color for each state to red or blue based on presidential election result and display a legend - 'Rep' label near the red box and 'Dem' label near the blue box. I am able to set colors in my code behind:
private void mapControl_Loaded(object sender, System.Windows.RoutedEventArgs e) { SolidColorBrush repBrush = new SolidColorBrush(Colors.Red); SolidColorBrush demBrush = new SolidColorBrush(Colors.Blue);
MapViewModel vm = (MapViewModel)this.DataContext; MapLayer layer = this.mapControl.Layers[0]; foreach (MapElement element in layer.Elements) { string caption = (string)element.GetProperty("Caption"); if (vm.statesData.Contains(caption)) { if ((string)vm.statesData[caption] == "R") element.Fill = repBrush; else element.Fill = demBrush; } } }
It works fine. Then in XAML file I set ValueScale:
<ig:MapLayer.ValueScale> <ig:DistributionScale IsAutoRange="False" ValueStopCount="2" ValueStops="0 1"/> </ig:MapLayer.ValueScale>
Then I set MapColorSwatchPane:
<ig:MapColorSwatchPane Margin="15" DisplayMode="Sample" LayerName="statesLayer" ig:XamDock.VerticalDockAlignment="Bottom" ig:XamDock.HorizontalDockAlignment="Right" ig:XamDock.Edge="InsideRight">
and I got a legend with 0 on top of red box and 1 on top of blue box. How can I set custom labels in the legend ?
I have been looking into your requirement and I have tried to change the labels text(accessing their Textbox element by style) using converter but it seems that their values are set through code.
After some research the functionality that you are looking for has been determined to be a new product idea. I have sent your product idea directly to our product management team. Our product team chooses new product ideas for development based on popular feedback from our customer base. Infragistics continues to monitor application development for all of our products, so as trends appear in requested ideas, we can plan accordingly.
We value your input, and our philosophy is to enhance our toolset based on customer feedback. If your idea is chosen for development, you will be notified at that time. Your reference number for this product idea is PI13010047.
If you would like to follow up on your product idea at a later point, you may contact Developer Support management via email. Please include the reference number of your product idea in the subject and body of your email message. You can reach Developer Support management through the following email address: dsmanager@infragistics.com
Thank you for your request.
Thank you very much,