- Home
- Forum
- Xamarin.Forms
- Binding MarkerTemplate and changing it at runtime in viewModel
Binding MarkerTemplate and changing it at runtime in viewModel
Hello,
I'm trying to change MarkerTemplate property of syncfusion map on the fly, as it is bound to a viewModel property that changes of value in commands but it doesn't work, seems like template is not refreshing or binding is not working when changing it. The first time it displays, binding is working as I set it in the viewModel constructor.
Here is the sfMap
<maps:SfMaps x:Name="sfmap" EnablePanning="False" EnableZooming="False" BackgroundColor="Transparent">
<maps:SfMaps.Layers>
<maps:ShapeFileLayer x:Name="ShapeLayer" Uri="FRA_adm0.shp" MarkerTemplate="{Binding Path=BindingContext.MarkerDataTemplate, Source={x:Reference carouselView}}">
<maps:ShapeFileLayer.ShapeSettings>
<maps:ShapeSetting ShapeFill="{StaticResource PrimaryColorOne}" ShapeStroke="white" ShapeStrokeThickness="2" >
</maps:ShapeSetting>
</maps:ShapeFileLayer.ShapeSettings>
<maps:ShapeFileLayer.Markers>
<local:CustomMarker Latitude="46,350907" Longitude="2,617358"></local:CustomMarker >
<local:CustomMarker Latitude="48,86666667" Longitude="2,33333"></local:CustomMarker >
<local:CustomMarker Latitude="43,296482" Longitude="5,36978"></local:CustomMarker >
</maps:ShapeFileLayer.Markers>
</maps:ShapeFileLayer>
</maps:SfMaps.Layers>
</maps:SfMaps>
And in this Command I'm just changing the MarkerDataTemplate property (i.e property bound to sf MarkerTemplate property)
private void DisplayMarkerTemplate(string type)
{
switch (type)
{
case "car":
MarkerDataTemplate = (DataTemplate)Application.Current.Resources["CarMarkerDataTemplate"];
break;
default:
MarkerDataTemplate = (DataTemplate)Application.Current.Resources["BusMarkerDataTemplate"];
break;
}
}
I've got images that are binded to a tappedCommand to the viewModel and changes MarkerTemplate considering commandParameter
<Image WidthRequest="30" HeightRequest="30" Source="ic_point_of_view.png">
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Path=BindingContext.DisplayMarkerTemplateCommand, Source={x:Reference carouselView}}"
CommandParameter="Temperature"/>
</Image.GestureRecognizers>
</Image>
Any idea ?
Thanks.
SIGN IN To post a reply.
1 Reply
MP
Michael Prabhu M
Syncfusion Team
December 10, 2018 12:22 PM UTC
Hi Rjuken,
Based on the provided information we have checked your scenario by using tap command and we were able to reproduce the issue in Xamarin.Forms (Android and iOS), but is working fine in UWP.
Hence, we have considered a defect report in those platforms.
A support incident to track the status of this defect has been created under your account.
Please log on to our support website to check for further updates.
We have prepared a sample and verified your scenario by using tap command to change the marker template in UWP.
Please download the sample from the below location.
If your scenario is not covered in the above sample, please provide additional information on this. This would help us to resolve your issue quickly.
Thanks,
Michael
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
RD Rjuken Developments
- Dec 9, 2018 10:49 PM UTC
- Dec 10, 2018 12:22 PM UTC