Good afternoon, all!
I am trying to use the MVVM pattern in my silverlight application, and I'm trying to capture a mouse click on the map to use for identify. I can capture the actual map mouse click using an InvokeCommandAction, but I can't seem to figure out how to pass the geometry of the mouse click as a command parameter to use in my view model.
Is there any way to capture the clicked point on the map?
I know how to do this using the code-behind on the view, so if no other solution exists, I can carry on doing it that way, but if there's a view model friendly version, I'd much rather use that!
Here is the XAML from the view for the map:
<esri:Map x:Name="map" Background="White" IsLogoVisible="False" Layers="{Binding MapLayerCollection}" viewModels:MapViewModel.BindableExtent="{Binding MapExtent}" Grid.RowSpan="2" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseClick">
<i:InvokeCommandAction Command="{Binding MapMouseClick, Mode=OneWay}" CommandParameter="<something to capture mouse click here>"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</esri:Map>
And here is the code from the view model:
public ICommand MapMouseClick { get; private set; }
public MapViewModel()
{
//Set commands.
this.MapMouseClick = new DelegateCommand<object>(this.OnMapMouseClick, this.CanMapMouseClick);
}
protected void OnMapMouseClick(object arg)
{
//Nothing is passed in to the arg, so have nothing to use here yet.
}
protected bool CanMapMouseClick(object arg)
{
return true;
}
If there's any other information I can provide, please let me know!
Thanks, and have a great day!
Lisa