helloI have a map that reads the information from the SQL Server.Get from the database to represent 2 values.Clik Using a listbox, I want to be shown on the map with the value 1 or the value 2. The ultimate goal is to display the same as when you load the map the first time (by default with the value 1)Like the example http://labs.infragistics.com/silverlightdv/2010.3/ # / Samples / Map / BindingWCFDataFilteringSourceIf I do as an example, does not load any data.If I do it with the following code, the map changes but does not display any data:
Private Sub OnDataChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs) Dim ItemSeleccionado As ListBoxItem = sender.SelectedItem Dim TextoSeleccionado As String = ItemSeleccionado.Tag.ToString Dim converter As New DataMapping.Converter()
Select Case TextoSeleccionado Case "Facturacion"
Dim sqlReader As SqlShapeReader = TryCast(xamMap.Layers("CapaAutonimias").Reader, SqlShapeReader) sqlReader.DataMapping = TryCast(converter.ConvertFromString("Data=geom;Name=NAME_1; Caption=NAME_1;Value=ValorF"), DataMapping) xamMap.Layers("CapaAutonimias").Reader = sqlReader xamMap.Layers("CapaAutonimias").ToolTip = "{}{Name}: Facturación {Value:n0} €"
Case "Ventas" Dim sqlReader As SqlShapeReader = TryCast(xamMap.Layers("CapaAutonimias").Reader, SqlShapeReader) sqlReader.DataMapping = TryCast(converter.ConvertFromString("Data=geom;Name=NAME_1; Caption=NAME_1;Value=ValorV"), DataMapping) xamMap.Layers("CapaAutonimias").Reader = sqlReader xamMap.Layers("CapaAutonimias").ToolTip = "{}{Name}: Ventas {Value:n0} Uds" End Select xamMap.Layers("CapaAutonimias").DataBind()
Thanks
Hi jcsanchezr,
MapLayer Reader's DataMapping is used in the process of mapping your objects to MapElements and changing if after that will not have any effect. As a workaround the following:
1. Set Reader's DataMapping in XAML or code behind:
DataMapping="Value=ValorF; Value2=ValorV"
2. In OnDataChanged iterate all map elements and set the new value
foreach (var element in xamMap.Layers[0].Elements){ //Case "Ventas" element.Value = Convert.ToDouble(element.GetProperty("Value2")); or //Case "Facturacion" element.Value = Convert.ToDouble(element.GetProperty("Value"));}
Regards,
Ivan Kotev
perfect.Can we do the same to change the ToolTip?Can you put in the concatenated values DataMapping?
For example: Name = Field1 + " " + Field2 + " €"
so that the result is "Spain € 33"Thanks
- Can we do the same to change the ToolTip?
- Yes, you can use this technic to dynamically change Map element's properties.
- Can you put in the concatenated values DataMapping?
- Unfortunately DataMapping doesn't support this. In order to possibly get this feature into a future release, please submit a feature request here http://devcenter.infragistics.com/SignIn/SignIn.aspx?ReturnUrl=%2fProtected%2fRequestFeature.aspx
ok.
Remove the first set of curl brackets - "{}", they are only used in XAML as an escape sequence.
How do you adjust dynamically ToolTip property?When I run the following code, no ToolTip is displayed on the map:
Case "Ventas"
Element.ToolTip = "{}{Name}: Ventas{Value:n0} Uds"
Case "Facturacion"
Element.ToolTip = "{}{Name}: Facturación {Value:n0} €"