We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Binding MarkerTemplate and changing it at runtime in viewModel

Thread ID:





141389 Dec 9,2018 10:49 PM UTC Dec 10,2018 12:22 PM UTC Xamarin.Forms 1
Tags: SfMaps
Rjuken Developments
Asked On December 9, 2018 10:49 PM UTC


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:ShapeFileLayer x:Name="ShapeLayer" Uri="FRA_adm0.shp" MarkerTemplate="{Binding Path=BindingContext.MarkerDataTemplate, Source={x:Reference carouselView}}">
                                    <maps:ShapeSetting  ShapeFill="{StaticResource PrimaryColorOne}" ShapeStroke="white" ShapeStrokeThickness="2"  >
                                    <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 >

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"];
                    MarkerDataTemplate = (DataTemplate)Application.Current.Resources["BusMarkerDataTemplate"];

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">
                                <TapGestureRecognizer Command="{Binding Path=BindingContext.DisplayMarkerTemplateCommand, Source={x:Reference carouselView}}"

 Any idea ?

Michael Prabhu M [Syncfusion]
Replied On 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. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon