Is it good MVVM practice keep Draw out of the ViewModel, (and only in the View)?If so, how can I do that?The VM needs the eventargs when DrawComplete fires, so I�??ve tried using MVVM Light�??s EventToCommand, but it throws an exception saying:Cannot attach type "EventToCommand" to type "Draw". Instances of type "EventToCommand" can only be attached to objects of type "FrameworkElement".
<UserControl x:Class="GeoidApp2.TestPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<UserControl.Resources>
<esri:SimpleLineSymbol x:Key="DrawLineSymbol" Color="Green" Width="4" />
<esri:SimpleFillSymbol x:Key="DrawFillSymbol" Fill="#3300FF00" BorderBrush="Green" BorderThickness="2" />
<esri:Draw x:Key="MyDraw" LineSymbol="{StaticResource DrawLineSymbol}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="DrawComplete">
<!--<ei:CallMethodAction TargetObject="{Binding}" MethodName="DrawDone"></ei:CallMethodAction>-->
<cmd:EventToCommand Command="{Binding DrawCompleteCommand,
Mode=OneWay}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
</esri:Draw>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<esri:Map x:Name="Map" Background="White" WrapAround="true" Loaded="Map_Loaded">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding MapLoadedCommand}"
CommandParameter="{Binding ElementName=Map}" />
</i:EventTrigger>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding WireDrawCommand}"
CommandParameter="{StaticResource MyDraw}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<esri:ArcGISTiledMapServiceLayer ID="BaseLayer"
Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
</esri:Map>
</Grid>
</UserControl>