viewmodel

ItemsControl with multiple DataTemplates for a viewmodel

[亡魂溺海] 提交于 2019-11-27 03:58:42
is it possible to bind an itemscontrol with canvas as template to multiple DataTemplates? I have 2 collections and depending on the type I would like to display a different control on my canvas. I am not sure but I could think about a Viewmodel which has 2 ObservableCollections. For example if I would have "Shapes" and "connections" and I would like to display them both on the canvas? In case of a diagraming scenario... I would like to do this in the mvvm manner and I am not sure if the multiple DataTemplate approach is correct but this came to my mind. But I am still having problems to get

WPF - Should a user control have its own ViewModel?

99封情书 提交于 2019-11-27 03:41:14
I have a window made up of several user controls and was wondering whether each user control have its own ViewModel or should the window as a whole have only one ViewModel? Kent Boogaart This is not a yes or no question. It depends on whether having extra view models affords you better maintainability or testability. There's no point adding view models if it doesn't gain you anything. You'll need to gauge whether the overhead is worth it to your particular use case. Absolutely, positively NO Your UserControls should NOT have ViewModels designed specifically for them. This is, in fact, a code

MVVMCross changing ViewModel within a MvxBindableListView

﹥>﹥吖頭↗ 提交于 2019-11-27 02:10:19
Little problem with my Android application and I don't know how to solve it with MVVM Cross. Here is my Model public class Article { string Label{ get; set; } string Remark { get; set; } } My ViewModel public class ArticleViewModel: MvxViewModel { public List<Article> Articles; .... } My layout.axml ... <LinearLayout android:layout_width="0dip" android:layout_weight="6" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/layoutArticleList"> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/editSearch" android:text

ViewModels or ViewBag?

≡放荡痞女 提交于 2019-11-27 01:57:09
I'm fairly new to MVC4, EF5 and ASP.Net, and I don't seem to be able to find a good answer anywhere. Basically, Should everything be done through the viewmodel or is it Ok to also incorporate viewbag? Say I have a method which populates a drop down list, and I am using a viewmodel to represent the output for the view. Am I ok to use Viewbag.DropDown = PopulateDropdown(); or would it be better to incorporate this into the ViewModel, by creating a property to hold the List<SelectListItem> created by PopulateDropdown(); ? I know how handy ViewBag is, but I'm yet to see any solid reason as to not

LiveData is not updating its value after first call

老子叫甜甜 提交于 2019-11-27 01:50:57
问题 I have been beating my head against the wall and I cannot understand why this is happening. I am working with the new Architectural Components for Android and I am having problems updating a LiveData with a List of Objects. I have two spinners. When i change the option in the first one, The second one must have its content changed. But this last part is not happening. Can anyone help me? State.java @Entity(tableName = "states") public class State{ @PrimaryKey(autoGenerate = false) private int

how to design ViewModel

亡梦爱人 提交于 2019-11-27 01:42:05
问题 I have EF 4 implemented in the project. Within it, there are tables customer and order. Which has relationship one (customer) to many (order). I'm creating a viewmodel for both (CustomerViewModel and OrderViewModel) to be passed from my domain layer to interface layer (MVC in this case). Now the question is "do I need to reference both viewmodel? for example in customerviewmodel has IEnumerable<OrderViewModel> and in orderviewmodel has CustomerViewModel . If so how do I design it (as a best

Using Automapper to update an existing Entity POCO

时间秒杀一切 提交于 2019-11-27 01:37:00
问题 I am using EF4 DbContext to provide the model for an ASP.NET MVC app. I use ViewModels to provide data to the views and Automapper to perform the mapping between the EF POCOs and the ViewModels. Automapper does a great job but I'm not clear the best way to use it after the ViewModel is posted back to the controller to carry out an update. My idea is to get POCO object using a key contained in the ViewModel. I then want to use Automapper to update the POCO with data from the ViewModel:

WPF Event Binding to ViewModel (for non-Command classes)

巧了我就是萌 提交于 2019-11-27 01:34:47
问题 I'm working an the second version of an application, and as part of the rewrite I have to move to an MVVM architecture. I'm getting pressure to put absolutely every bit of code in the view model class--having c# in the code behind file is frowned upon. (I know, I know...I understand that code behind isn't a bad thing, but it isn't my call this time). For objects which implement the command interface, it's easy. I've been able to find a ton of information on how to bind the Command of these

Share ViewModel between fragments that are in different Activity

て烟熏妆下的殇ゞ 提交于 2019-11-27 01:24:21
问题 I have a ViewModel named SharedViewModel: public class SharedViewModel<T> extends ViewModel { private final MutableLiveData<T> selected = new MutableLiveData<>(); public void select(T item) { selected.setValue(item); } public LiveData<T> getSelected() { return selected; } } I implement it based on SharedViewModel example on the Google's Arch ViewModel reference page: https://developer.android.com/topic/libraries/architecture/viewmodel.html#sharing_data_between_fragments It is very common that

MVC3 - Viewmodel with list of complex types

不打扰是莪最后的温柔 提交于 2019-11-27 00:57:13
问题 Apologies if this has been asked before; there are a million ways to phrase it so searching for an answer has proved difficult. I have a viewmodel with the following properties: public class AssignSoftwareLicenseViewModel { public int LicenseId { get; set; } public ICollection<SelectableDeviceViewModel> Devices { get; set; } } A simplified version of SelectableDeviceViewModel would be this: public class SelectableDeviceViewModel { public int DeviceInstanceId { get; set; } public bool