mvvm
Should the MVVM ViewModel perform type conversion/validation?
This is a very interesting question and one that I don’t feel has a definitive answer, but I’ll do my best to throw my thoughts out there. Looking at the MVVM pattern as I understand it, the point of the ViewModel is to expose the data in a way the View can understand without any …
“Are you sure?” prompts. Part of the ViewModel or purely the view?
The prompts should definitely not be part of the ViewModel, but this doesn’t necessarily mean that the best solution is to hardcode them in the View (even though that’s a very reasonable first approach). There are two alternatives that I know of which can reduce coupling between View and ViewModel: using an interaction service, and …
MVVM: Modified model, how to correctly update ViewModel and View?
When the view binds directly to the model (which is also the case when the ViewModel exposes the Model) you are mixing UI code and data code. The goal of MVVM is to separate these two code domains. That’s what the ViewModel is for. The view model has to have it’s own properties the view …
Binding a WPF ShortCut Key to a Command in the ViewModel
The following code can be used to bind a shortcut key directly to a command: <Window.InputBindings> <KeyBinding Command=”{Binding Path=NameOfYourCommand}” Key=”O” Modifiers=”Control”/> </Window.InputBindings> Add this after Window.Resources in the XAML code of your view.
WPF: Binding a ContextMenu to an MVVM Command
The problem is that the ContextMenu it not in the visual tree, so you basically have to tell the Context menu about which data context to use. Check out this blogpost with a very nice solution of Thomas Levesque. He creates a class Proxy that inherits Freezable and declares a Data dependency property. public class …
In MVVM, is every ViewModel coupled to just one Model?
In my understanding of the MVVM pattern, the only practical requirement is that the View gets all its data from the properties of a ViewModel (probably through a binding mechanism). The ViewModel is a class that you craft specifically for that view, and takes on the responsability of populating itself as required. You could think …
Scroll WPF ListBox to the SelectedItem set in code in a view model
Have you tried using Behavior… Here is a ScrollInViewBehavior. I have used it for ListView and DataGrid….. I thinks it should work for ListBox…… You have to add a reference to System.Windows.Interactivity to use Behavior<T> class Behavior public class ScrollIntoViewForListBox : Behavior<ListBox> { /// <summary> /// When Beahvior is attached /// </summary> protected override void …
Android MVVM: Activity with multiple Fragments – Where to put shared LiveData?
Late answer but I asked myself the same question and found the answer in Google guide. Especially for fragments, it is mentioned on Google Documentations explicitly here class SharedViewModel : ViewModel() { val selected = MutableLiveData<Item>() fun select(item: Item) { selected.value = item } } class MasterFragment : Fragment() { private lateinit var itemSelector: Selector …
MVVM radiobuttons
Take a look here. I haven’t implemented the solution provided but it makes sense. The underlying framework control breaks you bindings when a click is performed. The solution is to override the method that does this and just rely on the bindings.