In a view model, I have a collection of items of type "ClassA" called "MyCollection". ClassA has a property named "IsEnabled".
class MyViewModel
{
List<ClassA> MyCollection { get; set; }
class ClassA { public bool IsEnabled { get; set; } }
}
My view has a datagrid which binds to MyCollection. Each row has a button whose "I...
Hi all,
How would you suggest I write a unit test to check that a UI object is bound to a particular named property in my ViewModel?
Thanks,
Mark
...
I have a very similar issue as described in this post.
I have a UserControl to encapsulate an address. This contains a number of basic controls, mostly textboxes. I then have backing dependecy properties in the code-behind for each property...
#region Line1
/// <summary>
/// Gets or sets the Line1.
/// </summary>
pub...
In my ViewModel I have two commands:
ICommand ExecuteMeOnCheck { get; }
ICommand ExecuteMeOnUncheck { get; }
I wish to attach these commands to a CheckBox and have one of them execute when it is checked and the other execute when it is unchecked. What's the best way to achieve this without cluttering the View with code-behind?
...
It seems that ViewModels that I make look suspiciously like other classes and they seem to require a lot of code repetition, e.g. in a current project I have:
SmartForm: Model that represents a data form to fill in, has properties:
IdCode
Title
Description
collection of SmartFormFields
etc.
SmartFormControlView View
SmartFormControlV...
In my view I have this:
<TextBlock Text="{Binding Title}"/>
which binds to my ViewModel's Title property and this is straightforward and works well:
private string _title;
public string Title
{
get
{
return _title;
}
set
{
_title = value;
OnPropertyChanged("Title");
}
}
However my Vi...
I'm trying to understand the basic MVVM design approach when using ItemsControl by binding it via DataTemplates to ObservableCollections on the ViewModel.
I've seen examples that bind to ObservableCollections of strings, Views, and ViewModels.
Binding to strings seems to be only for demos, it is the binding to "ViewModels that contain ...
My MainView.xaml contains my SmartForm View:
<Grid Margin="10">
<views:SmartForm/>
</Grid>
the SmartForm view loads an ItemsControl
<Grid Margin="10">
<ItemsControl
ItemsSource="{Binding DataTypeViews}"/>
</Grid>
which is an ObservableCollection of DataTypeViews:
List<FormField> formFields = new List<FormField>();
...
Im trying to introduce the pattern to my team here in my company, but the bosses are reticent about going with WPF, cause they argue everyone has Windows Forms skills but no body has put its feet in WPF land yet, which is quite reasonable I guess. Yet the project would benefit from MVVM a great deal, I guess
...
OK, working on WPF(using MVVM) and came across a question, want some input. I have a simple class
like below(assume I have IDataErrorInfo implemented):
public class SimpleClassViewModel
{
DataModel Model {get;set;}
public int Fee {get { return Model.Fee;} set { Model.Fee = value;}}
}
I then try to bind to it in xaml:
<TextBox Te...
Hi girls and guys!
I'm currently in the planning phase for a project of mine.
I thought about using the MVVM-pattern for my application for testability, maintainability etc. I have only started to get my head around MVVM but there is one thing that I just can't figure out in the context of my planned application.
My application aims t...
I am wondering about how to approach inheritance with View Models in the MVVM pattern. In my application I have a Data Model that resembles the following:
class CustomObject
{
public string Title { get; set; }
}
class CustomItem : CustomObject
{
public string Description { get; set; }
}
class CustomProduct : CustomItem
{
...
I'm developing a WPF application using the MVVM pattern and I need to display a list of items in a ListView (with filtering), with the fields of the selected item displayed in a Master/Detail view. I'm torn between the following two ways of doing this:
Exposing a CollectionView in my ViewModel, and binding to this.
Exposing a plain ILi...
I download command behavior from web and have implemented in my silverlight project. Now I am trying to figure out how to unit test ICommand properties. I know lots of people are working on this, so if you have a good simple example of unit testing ICommand, please let me know.
Thanks
Dev
...
How how do you do this in c#?
<TextBlock Text={Binding MyProperty}/>
Assume the DataContext is set to a class of Type MyClass
...
I can see two ways to hook up the ViewModel to the View. One is in XAML and the other thru dependancy injection in the code behind.
Which method is more preferable? I prefer the xaml method because I don't want any code in the code behind at all, but is there any issues with one over the other?
<navigation:Page x:Class="MyNamespace.MyV...
Should MVVM be used for WinForms? If so, what is the advantage over using MVP?
...
I'm tracking ListView selection changes in an MVVM design by binding to IsSelected. I also need to track the current item by enabling IsSynchronizedWithCurrentItem.
I find that when I have two ListView binding to the same collection I get the InvalidOperationException: "Collection was modified; enumeration operation may not execute." ...
Recently there have been a lot of move towards MVVM framework due to the nature of WPF development. I am making a pretty small application, which might grow a little over time. I am curious to know, what sized application should benefit from a MVVM implementation. For example .. has to have 15 user screens to be beneficial or something l...
Hello, My name is Jesús from Spain, I'm a .NET developer and I just discovered this great web few days ago.
I have some questions about MVVM pattern and I will be glad if you can answer they.
I started WPF 3 months ago and I learned the MVP pattern. MVP is so good because you can structure the app so well.
I started seeing the mvvm pa...