<ListBox ItemsSource="{Binding ItemVMs}"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" /> </Style> </ListBox.ItemContainerStyle> </ListBox>
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
<ComboBox ItemsSource="{Binding States}" SelectedItem="{Binding CurrentState}" Height="25" Width="120"/>
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.
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
<i:Interaction.Triggers> <i:EventTrigger EventName="Loaded"> <i:InvokeCommandAction Command="{Binding ConverterParameter=SetMap, Converter={framework:CommandGenerator} }" CommandParameter="{Binding ElementName=MyMap}" /> </i:EventTrigger> </i:Interaction.Triggers>
We ran into the same problems building ArcGIS Explorer Online with the ArcGIS Silverlight API, and most recently with the ArcGIS Viewer for Windows and the WPF API. I'm at the DevSummit this week (and actually doing a session on MVVM) so if you're around I'd love to talk with you about it. When I have some spare cycles I'll put together some thoughts on how we've approached MVVM and the Map control and post it back to this thread.-Jeff
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.