KnockOutJS – Multiple ViewModels in a single View

Knockout now supports multiple model binding. The ko.applyBindings() method takes an optional parameter – the element and its descendants to which the binding will be activated. For example: ko.applyBindings(myViewModel, document.getElementById(‘someElementId’)) This restricts the activation to the element with ID someElementId and its descendants. See documentation for more details.

Binding a WPF ComboBox to a custom list

You set the DisplayMemberPath and the SelectedValuePath to “Name”, so I assume that you have a class PhoneBookEntry with a public property Name. Have you set the DataContext to your ConnectionViewModel object? I copied you code and made some minor modifications, and it seems to work fine. I can set the viewmodels PhoneBookEnty property and … Read more

AndroidViewModel vs ViewModel

AndroidViewModel provides Application context If you need to use context inside your Viewmodel you should use AndroidViewModel (AVM), because it contains the application context. To retrieve the context call getApplication(), otherwise use the regular ViewModel (VM). AndroidViewModel has application context. We all know having static context instance is evil as it can cause memory leaks!! … Read more

What is difference between MVC, MVP & MVVM design pattern in terms of coding c#

Some basic differences can be written in short: MVC: Traditional MVC is where there is a Model: Acts as the model for data View : Deals with the view to the user which can be the UI Controller: Controls the interaction between Model and View, where view calls the controller to update model. View can … Read more

MVVM: Tutorial from start to finish?

Your question really seems to be asking 2 questions: Where are some good tutorials on WPF, assuming I have no previous WPF experience? Where are some good tutorials on learning MVVM? Some of these resources may be duplicated in previous answers… Tutorials on WPF A Guided Tour of WPF by Josh Smith I wrote a … Read more

Handling Dialogs in WPF with MVVM

I suggest forgoing the 1990’s modal dialogs and instead implementing a control as an overlay (canvas+absolute positioning) with visibility tied to a boolean back in the VM. Closer to an ajax type control. This is very useful: <BooleanToVisibilityConverter x:Key=”booltoVis” /> as in: <my:ErrorControl Visibility=”{Binding Path=ThereWasAnError, Mode=TwoWay, Converter={StaticResource booltoVis}, UpdateSourceTrigger=PropertyChanged}”/> Here’s how I have one implemented … Read more

Data binding to SelectedItem in a WPF Treeview

I realise this has already had an answer accepted, but I put this together to solve the problem. It uses a similar idea to Delta’s solution, but without the need to subclass the TreeView: public class BindableSelectedItemBehavior : Behavior<TreeView> { #region SelectedItem Property public object SelectedItem { get { return (object)GetValue(SelectedItemProperty); } set { SetValue(SelectedItemProperty, … Read more

How should the ViewModel close the form?

I was inspired by Thejuan’s answer to write a simpler attached property. No styles, no triggers; instead, you can just do this: <Window … xmlns:xc=”clr-namespace:ExCastle.Wpf” xc:DialogCloser.DialogResult=”{Binding DialogResult}”> This is almost as clean as if the WPF team had gotten it right and made DialogResult a dependency property in the first place. Just put a bool? … Read more

tech