viewmodel

How to prevent a ListView from expanding the window dimension?

Hi, I put a ListView in the middle row of a View. The view is contained in a window that has SizeToContent set to WidthAndHeight. The ListView is initially empty, but the underlying ViewModel fills this list view in the process. The middle Grid.Row height is set to * to fill the available size of the window. When the ListView receives ...

IsSelected property of ViewModel bound to ListBox, Only FIRST item selection works ?

Hello, I have a MeetingViewModelList bound to a DataGrid. Each MeetingViewModel has a DocumentViewModelList bound to a ListBox within the DataGrid`s DataGridTemplateColumn. The IsSelected property of the DocumentViewModel is bound to the ListBox`s Item property IsSelected. I get no binding errors in the output console. The delete d...

ASP.NET MVC Default View Model Binding of cookies to custom objects

Does the ASP.NET MVC 2 Default View Model Binding support binding a multi-value cookie to a custom object? Before I write a custom Value Provider, I would like to be sure that the functionality didn't already exist. So given an action like: public ActionResult SomeAction(CustomObject foo) where CustomObject is something like: public...

Call the repository`s CRUD-methods from the Controller or ViewModel ?

Hello all, thats the way josh smith is doing the add-a-customer-procedure: **CustomerViewModel**.cs: public void Save() { _customerRepository.AddCustomer(_customer); } **CustomerRepository**.cs: public void AddCustomer(Customer customer) { //... _cus...

What's a good HTML naming convention for model binding complex nested types?

If I have an object that is composed of nested complex types, e.g. a ViewModel that has a List<Fu> and a List<Bar> public class WarViewModel { List<Fu> Fu { get; set; } List<Bar> Bar { get; set; } } public class Fu { public int Id {get;set;} public Soldier Private { get; set; } } public class Bar { public int Id {g...

Validation with nested ViewModels in ASP.NET MVC2

I'm having a weird (at least to me) problem with validation using ViewModels and Html.EditorFor(T). The validation errors produced by <%: Html.ValidationSummary(false) %> lists properties which are not invalid, and do not correspond to the values in the ModelState dictionary when I view it in debug. I'm using strongly typed view models c...

PropertyChangedEventHandler is null in FirePropertyChanged

Hi, I have a viewmodel named EmployeeViewModel which is inherited from ViewModelBase. here is the implementation of ViewModelBase. public event PropertyChangedEventHandler PropertyChanged; public void FirePropertyChanged(string propertyname) { var handler = PropertyChanged; if (handler != null) ha...

How to save data from a DetailView bound to a ViewModel if the repository is a no-go in a viewmodel ?

Hello, we mvvm lovers all know Josh Smith mvvm sample and how he has saved the customer in the detail customer view by injecting the repository object into the customerViewModel`s constructor. But a viewmodel should not know about repositories. Its just a model of a view nothing must being aware of persistence etc... How can I registe...

When ONE View has ONE ViewModel then a Customer-Order-Product relation/gui can get very nasty...

I think I got some sort of knowledge flash and now I am totally confused. I looked at many mvvm implementations like Ocean,Stuff,BBQShack,MVVM demo,WAF,Chinch1,2 etc... Everyone is doing MVVM differently somehow... There is ONE scenario that drives me nuts. I am missing understanding and I hope someone can clear the clouds in my head. ...

Automapper string to enum

Hi All, I've found a couple of posts that describe similar scenarios to mine but nothing that has the same concept or has been resolved so I'm sure I will get complaints about this question but I still want to ask it so some of you more knowledgeable than my self can give me some advice. My problem is hydrating a Viewmodel from a Lin...

ASP.NET MVC: having one model for all views

I like the way model binding in django works: you send stuff that you need in a Json-like way: 'param1': val, 'param2': val In ASP.NET MVC you can't do it primarily because C# is a static language. You can use ViewData but it's ugly and not recommended. So I had to create dozens of ViewModels for every view: IndexViewModel, AboutView...

How to get TextBox inside DataTemplate in a ListBox to notify the ViewModel on value change

What I need to find is when a textbox's value is changing or the dropdown's value changes inside my datatemplate item, I need to be notified in my ViewModel.cs. So basically as a user edits a textbox inside the listbox, the viewmodel will be notified as the values are changing. The reason is I need to go through all my Entries and upda...

Communication between ViewModels

Hi! I have two questions regarding communication between ViewModels. I am developing a customer management program. I'm using Laurent Bugnion's MVVM Light framework. In the main page, there's a list of customers. when each customer is clicked, a child windows shows up with information about that customer. the user should be able to o...

What is a model.cs file?

What is a model.cs file? This appears in a project I am sharing with other dev's. What is a model.cs file? ...

Make child window always on top of parent window

Hello, I'm writing in wpf. In my viewModel I have a command that opens new window. However sometimes this child window is placed under the parent window. (if for instance I work in my application, then open browser and want to return to my application). Window is opened as follows: MyViewModel vm = new MyViewModel(oper); Mywindow wind...

ASP.NET MVC: How do I handle a view model with many properties?

So I have an almost 1:1 ratio of views to view models and things seem to be going well. If I understand their purpose correctly it seems that view models should "Strip down" Entity models so that only relevant properties are passed to the presentation layer Add additional information needed for presentation such as a list of state abbrev...

Infinite Loop when binding slider in MVVM

I have a video progress slider in XAML thus: <Slider Minimum="0" Value="{Binding Position,Mode=OneWay}" Maximum="{Binding Duration}" IsMoveToPointEnabled="True"/> And code in my viewmodel to update Position on Clock.CurrentTimeInvalidated(), which keeps the slider tracking current progress: private void Play() { Uri next = _carousel....

How to track the property changed?

In Viewmodel, I want to track the status of async call. Suppose I have two async calls in viewmodel, I want to track when all async call done. What I did as below: Set to private var to track each async calls: private bool _isDone1 = false; private bool _isDone2 = false; Set one property like: private bool _isDone; public bool IsD...

ViewModel breaks UI automation in WPF

Hi, I have a WPF application that mostly follows MVVM, which I am trying to automate. In some of my user controls I bind the Content property to the ViewModel of another user control. There is a data template defined which maps the ViewModel to the correct View to show on the screen. This works fine for when the application is run b...

How do I update the status bar from multiple viewmodels?

I have MainWindow with a statusbar and multiple user controls in it. Each user control has a viewmodel. How do I bind/update the statusbar text from multiple viewmodels? ...