I am not aware that using PointDataSource is the preferred way to go with MVVM since. From the experience that I have got with working mainly with Silverlight, is that you can work with Graphic's in the ViewModels with no problem and there is no need to build a lot of extra-work-a-rounds since you can bind the graphics directly. I would be interested if other peoples have different view to this topic.
You can use quite a lot of different approaches here but I have been using GraphicCollection or ObservableCollection<Graphic> that I bind directly in XAML to graphics layer. You can look how you can do that from here http://forums.arcgis.com/threads/63189-GpsLayer-and-MVVM-issues?p=220140&viewfull=1#post220140 With this kind of approach you can easily use other stuff like Task's in very mannered way from the ViewModels (or from the application services since you probably won't want to bloat your VM's code with all that stuff).
Also one good way to abstract association code with the Graphics is to create custom list like in the "Using GraphicsSource Online"-example in the Samples.
Hope this helps.
Edit:
Jeff Jackson kept very good tutorial to MVVM development in Developer summit. I encourage people to check it out http://video.arcgis.com/watch/1185/software-development-and-design-using-mvvm
Hi,
I have been following this post since a long time and saw the examples above. It is really great work.
However from what I perceive of MVVM, my viewmodel should actually be totally unaware of the view. While when I try to implement the same in ESRI's SDK for WPF, it makes me use instance of Map in the ViewModel.
Has someone found a way to create a viewmodel that does not include a reference to ESRI? This somehow is the first requirement for the application I am developing.
public class PresentationModel { public interface View { void ZoomTo(Geometry geom); } public View View {get; set;} }
Keith,
If you want to wire up a method on your ViewModel to some arbitrary event, then you need to use something like the InvokeCommandAction which is defined in System.Windows.Interactivity. Then you can generate a command using the CommandGenerator and you're set.
In the case you describe though, you don't really need to use an event to determine if the ComboBox selection changes. You can simply bind to another property in your ViewModel instead.
For example, your view ComboBox might be defined like this:<ComboBox ItemsSource="{Binding States}" SelectedItem="{Binding CurrentState}" Height="25" Width="120"/>
By binding to the SelectedItem property, the setter on you ViewModel property (CurrentState) will get called any time the selection changes.
Hope that helps,
Jeff
<ListBox ItemsSource="{Binding ItemVMs}"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" /> </Style> </ListBox.ItemContainerStyle> </ListBox>