The example code uses a generated dbf file, but I need to get data at runtime based, for example "hugs per captia".
I get NaN in the legend when I tried the following code:
I get NaN in the legend when I tried the following code:
public partial class Example : UserControl { private bool initialized; private const string NonDbfDataField = "HugsPerCapita"; public Example() { InitializeComponent(); this.RadMap1.InitializeCompleted += new EventHandler(RadMap1_InitializeCompleted); } void RadMap1_InitializeCompleted(object sender, EventArgs e) { if (!this.initialized) { this.initialized = true; this.InformationLayer.Reader.PreviewReadCompleted += new PreviewReadShapesCompletedEventHandler(Reader_PreviewReadCompleted); } } private void Reader_PreviewReadCompleted(object sender, PreviewReadShapesCompletedEventArgs eventArgs) { if (eventArgs.Error == null) { foreach (MapShape shape in eventArgs.Items) { this.SetAdditionalData(shape); } } } private void SetAdditionalData(MapShape shape) { ExtendedData extendedData = shape.ExtendedData; if (extendedData != null) { // add new property to ExtendedData if (!extendedData.PropertySet.ContainsKey(NonDbfDataField)) { extendedData.PropertySet.RegisterProperty(NonDbfDataField, "", typeof(int), 0); } string country = (string)shape.ExtendedData.GetValue("ISO_2DIGIT"); int additionalFieldValue = this.GetHugsByCountry(country); // assign value to new property shape.ExtendedData.SetValue(NonDbfDataField, additionalFieldValue); } } private int GetHugsByCountry(string stateName) { return 43 ; } }