Xamarin Forms Map, MoveToRegion in custom event handler not working

BekzodIsakdjanovBekzodIsakdjanov CZMember
edited December 2015 in Xamarin.Forms

Hello everyone,
Can anyone please tell why
Map.MoveToRegion(.FromCenterAndRadius(somePosition,.FromKilometers(0.5)));
works in implemented events, but in a custom control the custom event is fired and the moveToRegion is called but nothing happens.

Here is the part of the XAML layout of control the control

<controls1:CarouselLayout x:Name="CarouselLayout"
                ItemsSource="{Binding Path=Doctors}"
                SelectedItem="{Binding Path=SelectedDoctor}"">
                <b:Interaction.Behaviors>
                    <b:BehaviorCollection>
                        <b:EventToCommand
                            EventName="SelectionChanged"
                            Command="{Binding MoveToMapRegionCommand}"
                            CommandParameter="{x:Reference mapa}" />
                    </b:BehaviorCollection>
                </b:Interaction.Behaviors>
</controls1:CarouselLayout>

and in CarouselLayout.cs I declare the event like this
public event EventHandler<SelectedItemChangedEventArgs> SelectionChanged;

and in MoveToMapRegionCommand.cs I execute it like this

     public void Execute(object parameter)
            {
                var Map = (Map) parameter;
                var doctorPos = ViewModel.SelectedDoctor.Address.Position;
                Map.MoveToRegion(
                        MapSpan.FromCenterAndRadius(new Position(doctorPos.Latitude - 0.002328, doctorPos.Longtitude),
                            Distance.FromKilometers(0.5)));
            }

if subscribe to event for example Focused the same code works
the event is fired properly but moveToRegion as said does not do anything, I believe that the problem is in the signature of my event.
If the code is not enough, please tell me I will post the full code, the reason why I haven't done it is because the post will be too long and redundant code which doesn't affect my problem will be filled all over the place.

Sign In or Register to comment.