viewmodel

Binding to viewmodel from inside a datatemplate

自古美人都是妖i 提交于 2019-11-30 10:57:02
I have multiple videos displayed they are bound with a videocollection in Mainviewmodel. Everything works fine untill I try to bind the enter command to Mainviewmodel. I Don't know the syntax for this. As it stands the binding is set to Video and not Mainviewmodel. Errormessage: 'StartVideoCommand' property not found on 'object' ''Video' Xaml: <Window.Resources> <local:MainViewModel x:Key="MainViewModel"/> </Window.Resources> <Grid DataContext="{StaticResource MainViewModel}"> <ListBox ItemsSource="{Binding Videos}"> <ListBox.ItemTemplate> <DataTemplate> <Grid> <Grid.InputBindings> !!!

TabControl disposes of controls on inactive tabs

时光怂恿深爱的人放手 提交于 2019-11-30 10:22:25
I'm using the MVVM pattern for my app. The MainWindow comprises a TabControl with the DataContext mapped to the ViewModel: <Window.Resources> <ResourceDictionary> <DataTemplate x:Key="templateMainTabControl"> <ContentPresenter Content="{Binding Path=DisplayName}" /> </DataTemplate> <local:ViewModel x:Key="VM" /> <local:WorkspaceSelector x:Key="WorkspaceSelector" /> <local:TabOneView x:Key="TabOneView" /> <local:TabTableView x:Key="TabTableView" /> <DataTemplate x:Key="TabOne"> <local:TabOneView /> </DataTemplate> <DataTemplate x:Key="TabTable"> <local:TabTableView /> </DataTemplate> <

How to handle view model with multiple aggregate roots?

耗尽温柔 提交于 2019-11-30 09:55:46
At the moment, i got quite badly fashioned view model. Classes looks like this=> public class AccountActionsForm { public Reader Reader { get; set; } //something... } Problem is that Reader type comes from domain model (violation of SRP). Basically, i'm looking for design tips (i.e. is it a good idea to split view model to inputs/outputs?) how to make my view model friction-less and developer friendly (i.e. - mapping should work automatically using controller base class)? I'm aware of AutoMapper framework and i'm likely going to use it. So, once more - what are common gotchas when trying to

MVVM View event Viewmodel command binding

回眸只為那壹抹淺笑 提交于 2019-11-30 09:37:40
问题 I'm looking for a good (read: simple) example on how to implement event aggregators with Prism. I've never used Prism and I'm also quite new to MVVM itself. I have a WPF canvas as a View and I want to handle the MouseUp event on the canvas in the Viewmodel. Now the powers that be at our organization wants me to use Prism, and apparently Prism recommends using event aggregators, which is why I need a sample to get me started. 回答1: all you need for this is the EventToCommand behavior from

Can jQuery do a POST of a ViewModel to a Controller in ASP.NET MVC?

一曲冷凌霜 提交于 2019-11-30 09:13:33
I have my Html Textboxes created so that they will be bound to a custom view model when posting back to the server. <%= Html.TextBox("CustomerFormViewModel.Email")%> This works great if it's a traditional POST. I can then receive it on the Controller side with something like this: [AcceptVerbs(HttpVerbs.Post)] public ActionResult AddCustomer(CustomersFormViewModel model) { //validate data, save customer, handle validation errors... } I want to know -- is it possible to do the POST via jQuery and still get the same behavior? It is possible, there is no difference between a "traditional POST"

ASP.NET MVC view model best practices

别等时光非礼了梦想. 提交于 2019-11-30 07:09:46
My ASP.NET MVC site connects to a WCF service to get data. The WCF service returns a data contract like this: [DataContract] public class Person { [DataMember] public string First { get; set; } [DataMember] public string Last { get; set; } } The view model in my MVC project looks like this: public class MyViewModel { public string SomeExtraField1 { get; set; } public string SomeExtraField2 { get; set; } public string SomeExtraField3 { get; set; } public Person Person { set; set; } } Should my view model be referencing the "Person" data contract that is returned from the data service? Or should

Bbinding combobox within dataform to view model property outside dataform's context

旧街凉风 提交于 2019-11-30 06:01:18
问题 I have two properties in my view model: //Relationship has property ReasonForEndingId private Relationship editRelationship; public Relationship EditRelationship { get { return editRelationship; } set { if (editRelationship != value) { editRelationship = value; RaisePropertyChanged(EditRelationshipChangedEventArgs); } } } //ReasonForLeaving has properties Reason & Id private IList<ReasonForLeaving> reasonsComboList { get; set; } public IList<ReasonForLeaving> ReasonsComboList { get { return

ASP.NET MVC ViewModel and DropDownList

ぐ巨炮叔叔 提交于 2019-11-30 05:44:23
问题 I have 2 properties in my ViewModel class ViewModel1 { Dictonary<int, string> PossibleValues {get;set;}//key/value int SelectedKey {get;set} } I want to edit this using a Html.DropDownListFor I want to get MVC to auto serialize the data into/from the ViewModel so I can the following public ActionResult Edit(ViewModel1 model) ... What's the best way to accomplish this? 回答1: As womp said, a browser will only submit the selected value of a drop down list. This is easily bound by the default

ASP.Net MVC Update ViewModel on DropDown Selection changed

别说谁变了你拦得住时间么 提交于 2019-11-30 05:43:36
问题 At first I'm absolutely new on web development. I'm trying to develop a Web application which consists of a single page (I started with an empty project trying to follow the mvc pattern). To populate my View I pass a ViewModel through my HomeController to my "Home"View. Now I want to change a few Label-Texts depending on a DropDown selection. ViewModel: public IEnumerable<Models.Language> AvailableLanguages; public Models.Language SelectedLanguage Public IEnumerable<Models.Text> Content;

How to I connect a ViewModel to a View when the view model has parameters in the constructor?

吃可爱长大的小学妹 提交于 2019-11-30 05:24:40
问题 I'm using Prism and Unity to rewrite a WPF application using the MVVM pattern. Most of the Views are connected to the VM via the DataContext property, like so: <UserControl.DataContext> <VM:RibbonViewModel/> </UserControl.DataContext> The problem is that this method will not work when there is a parameter in the ViewModel's constructor. public RibbonViewModel(IEventAggregator eventAggregator) { this.eventAggregator = eventAggregator; } I get the error: Type 'RibbonViewModel' is not usable as