Click here to Skip to main content
15,888,521 members
Everything / MVVM

MVVM

MVVM

Great Reads

by Sacha Barber
It would probably be like Cinch, an MVVM framework for WPF.
by Alan Beasley
Explanation and examples of Additional Templates and Generated Content of a ListBox. Covering Layout, Transitions, and Animation.
by Nish Nishant
An ExifReader class in C# that supports custom formatting and extraction. StyleCop compliant code, with demos for WPF and Windows Forms.
by defwebserver
How using the Silverlight DataTrigger allows you to run a process and then raise another when using View Model (MVVM)

Latest Articles

by Peter Sun (247)
Implement ChatGPT API in C# WPF with GPT3.5-turbo
by Federico Alterio
Description of a library that allows to use a porting of Angular Signals in .NET MVVM Frameworks
by Graeme_Grant
MVVM made simple via Blazing.Mvvm Library using the Microsoft Community Toolkit
by Jo_vb.net
How to get started using the MVVM Toolkit

All Articles

Sort by Updated

MVVM 

1 Nov 2010 by #realJSOP
Grid.SetColumn...
28 Jul 2011 by #realJSOP
You can:0) Implement a public method to initialize the variable (passing the path as a parameter to the method).1) Make a public property that can be set externally of the class that contains it2) If the variable only has to be set one time, you could pass the path as a parameter to...
1 Sep 2011 by #realJSOP
It's a simple matter of starting a new Silverlight navigation project. It adds everything to your app that you need to get started.
25 Oct 2016 by #realJSOP
The binding for the inner button's IsSelected property merely needs to refer to the value of it's parent control's IsSelected property, something like this:"IsSelected={Binding IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ToggleButton}}}"
5 Mar 2018 by #realJSOP
The model does nothing more than get/save/or delete data from the data source. The view should never directly call any method or refer to any property in the model. There are many ways to manage this interaction, but presenting a reasonably complete example in Q/A is beyond the intent of Q/A. ...
13 Mar 2018 by #realJSOP
I'm assuming you have one collection for the combobox, and one for the listbox. In your listbox collection item, add a property called IsVisible. When your combobox selection changes, set your new IsVisible property to true or false, depending on whether or not the item is associated with...
21 Mar 2018 by #realJSOP
Start by putting a breakpoint on the set method in your Checked property, and verify that the binding you've set up is actually working.
23 Mar 2018 by #realJSOP
So you want to log them in immediately upon swiping their card? That is pretty insecure because ANYBODY could swipe the card (even someone else's card). Two-factor authentication (something you have - the card, and something you know - your password) is highly recommended. If that's not what...
23 Mar 2018 by #realJSOP
In your XAML, add this attribute to the appropriate element(s): Grid.ColumnSpan=n (where "n" is the number of columns to span in your grid)
5 Nov 2018 by #realJSOP
Validation should be performed in the view or viewmodel. Check this article: Validation in WPF[^]
24 Jan 2019 by #realJSOP
So before you refresh the grid, get/retain the current cursor position, and restore that position after the refresh.
15 Oct 2019 by #realJSOP
Put your array of pages into a global static class. This makes your pages array available to any object. Another option is to put all of the pages into the main form's xaml, and set their Visibility property to Visibility.Collapsed. At that point, all you have to do is manage the Visibility...
13 Nov 2019 by #realJSOP
You don't disable commands - you disable the controls that invoke them. The view should be able to detect the error status and disable a control based on that status. That's how it's supposed to work.
25 Nov 2019 by #realJSOP
You could create a base window class with the appropriate event handler in it, and derive all your actual windows from that base class. At that point, you can add a Click event handler in the XAML and simply point it at the base class handler method. If you want to make it possible to override...
16 Dec 2019 by #realJSOP
You can bind the SelectedItem property in the combo box to a public property in your form. That means your form has to inherit/implement INotifyPropertyChanged. Another way is to handle the SelectionChanged event for the combo box, and set a method variable like so: MyType selected =...
11 May 2020 by #realJSOP
.Net Core is NOT ready for prime time. You shouldn't be using it in enterprise development until they release .Net 5.0, and even then, you should probably wait at least six months while they fix their half-assed code. If it's possible to mix...
4 Nov 2021 by #realJSOP
A tool to generate model and viewmodel classes directly from your selected database
7 May 2021 by #realJSOP
The only way I can think of to do what you want is to disable the entire main window. When the sub-process is launched, set IsEnabled to false in the main window class. BTW, this is a stupid design decision. Why not just open a form within the...
25 Jul 2021 by #realJSOP
Maintain a list of notifications, and any time that list contains 1 or more items, display the balloon. If there are more than one notification, provide a way for the user to move from one to the next (and back again).
12 Feb 2022 by #realJSOP
This might help: Update a WPF UI from Another Thread – Stephen Haunts { Freelance Trainer and Writer }[^]
23 Jan 2018 by .NetDev_1012
Hello, Is there a way to handle a UserControl Unloaded Event with MVVM in WPF? I've seen an example for a Window in this article: Handling a Window's Closed and Closing events in the View-Model[^] However, I tried modifying it for a UserControl, but to no avail. Thanks many! What I have...
21 Oct 2015 by 1234ctk
I need to do a project with 3-tieras I understand the 3 tier architecture work like that:I have the view-the UI of the user,I have the BLL that have the business logic and the DAL+Model-(I want to use in entity framework)-these three are different projects on the same solution and for...
6 Jul 2015 by 1sumitanand
On a Button click i'm opening a default browser with a desired Url.I want that in a loop inputted by the user it will have "F5" command executed that number of times.I am able to open the number of tabs should open in default browser but not the number of times it should refresh itself.
13 Apr 2016 by @nkit Bajpai
This article discuss a simple application built using WPF MVVM design pattern and explain the basics of Command Binding and DataBinding.
11 Jul 2013 by _Asif_
Yes, it is possible. You can do it using Reflection. Check thishttp://msdn.microsoft.com/en-us/library/aa288454(v=vs.71).aspx[^]
3 Dec 2013 by _Maxxx_
Using an extended MVVM pattern for real world LOB applications: Part 1
3 Dec 2013 by _Maxxx_
Using an extended MVVM pattern for real world LOB applications: Part 2
13 Dec 2013 by _Maxxx_
Using an extended MVVM pattern for real world LOB applications: Part 3
3 Dec 2013 by _Maxxx_
Using an extended MVVM pattern for real world LOB applications: Part 4
8 May 2013 by _Maxxx_
Interesting question.I'm not a big IOC user so what I offer may not be applicable.in my mvvm 'framework' my design time data (essentially view models) inherit from the run time view models.I initially put them in the view project with the views - but I just had a quick try and moved...
29 Oct 2013 by _Maxxx_
I guess your second user control is displaying data from the selected item in the list box?If so, then binding the listbox's SelectedItem property to your ViewModel will tell you if something is selected and, if so, what it is.You could then bind the visibility of your second user...
29 Oct 2013 by _Maxxx_
I'm not sure why you are using a UI_Model here? What would be there?I normally consume POCO data classes in my view model - and either wrap them or otherwise present the information to the ViewsI also separate my View and ViewModel into different projects in the solution, with the View...
1 Dec 2013 by _Maxxx_
Put simply, MVVM does not determine from where your model classes get their data - MVVM is just a pattern used for development.Your model classes could be plain old objects that you populate programatically (say via a datareader from a database, or from loading a CSV file from disk - MVVM...
9 Dec 2013 by _Maxxx_
The listview should be bound to a collection in the viewModel, the button should execute a command in the ViewModel.The command execution should add an article to the collection.Because the list view is bound to the collection, the new entry should be shown.
6 Jan 2014 by _Maxxx_
From your description I would think about having a base View class that has the ability of showing itself in a window or in an existing control.So, when you load/unload a view you can tell the View to either load itself into some container (as it presumably does now) or to pop itself up into...
15 Jan 2014 by _Maxxx_
You can't do what you are trying easily - setting the focus to a particular control is a pain in MVVM generally.It also goes against what MVVM is all about - the VM shouldn't really know focus is going to be set at all.If you do need to do it, you can use attached properties - see...
22 Jan 2014 by _Maxxx_
I'm not sure I entirely understand what you are asking, but it seems to me that you are allowing the user to change layout of controls, and want to save the layout to a database, where currently you save the layout to XML.It sounds to me like you would have a public method on a BaseViewModel...
26 Sep 2013 by _Noctis_
This tip shows the different results of using a ListBox in different panels, and the effects on scrolling.
20 Apr 2016 by _Noctis_
To save you from doing this every time you want a WPF/MVVM project, here it is, all rolled into one.
10 Dec 2012 by _yaRus_
Hello, CodeProject.I am working on implementation of MVP patter for WinForms application.I have the following View interface declaration:public interface IView{ event EventHandler ViewShown; event EventHandler ViewClosed; void...
10 Jul 2023 by A Belal
paid and remain Amount always saved null in database although i get value is not null by javascript What I have tried: my storedProcedure USE [OnlineMarket] GO /****** Object: StoredProcedure [dbo].[InsertintoSalesInvoice] Script Date:...
30 Dec 2013 by Aaditya parcha
Hi,i have a student class like belowpublic class Student { public int stdId { set; get; } public string stdName { get; set; } public string dept { get; set; } }and my controller code is public ActionResult Student() { ...
31 Jan 2018 by abboudi_ammar
Good evening everyone, I am looking to develop a simple application to understand MVVM architecture with WPF. I just want to insert a text entered in a text field entered on a listview when pressing the add button. I create two folders that are Template and ViewModel and here is the source code...
10 Feb 2018 by abboudi_ammar
I am a beginner at MVVM design patter and WPF I am trying to make a small example of connection to the MS Access database using the WPF and MVVM Light Toolkit patter design. but when i run the program it does not do anything and when i debug i find that the instruction stops at the instruction...
27 Feb 2018 by abboudi_ammar
Good evening, I try to link the window WPF "MainWindow" with another window WPF that I name it "window". I wrote a code with MVVMLight Toolkit and my question:does this confirm the MVVM design pattern, or how can I fix it? What I have tried: public class MainViewModel : ViewModelBase { ...
11 Dec 2009 by Abby Fichtner (Hacker Chick)
A tutorial and application on using WPF Data Binding with LINQ to SQL classes. This is part 3 of a three-part tutorial on using LINQ to SQL.
22 Aug 2010 by Abhinav S
You might also want to consider using Microsoft Prism[^].Any view consisting of another view could actually be broken up into sub regions within regions thus breaking your complex view into smaller ones. You will need to have a look at the Prism documentation and understand it before you...
5 Dec 2010 by Abhinav S
One way to do this could be by using event aggregators[^].When to use an event aggregator and when not is always a debatable topic though.
14 Jan 2011 by Abhinav S
You could start with this[^] article.
18 Apr 2011 by Abhinav S
You can avoid float calculations if possible - as far as i know, progress bar understand int so why use float - float calculations are slower. Other than that, this looks good code IMO.
17 Jul 2011 by Abhinav S
There are two ways to do this.The simpler way is to obviously pass an instance of the detail object to your details view model and then let the view model take care of the binding to the actual view.if you want to decouple the master and detail however, you can use an...
9 Aug 2011 by Abhinav S
You can use an Action delegate to go back to the first view when edit is clicked in the second view.
5 Feb 2012 by Abhinav S
Since there is no binding available for password boxes, attached properties are the only choice.
15 Jun 2012 by Abhinav S
Why the Validation Applied in the Model Class instead Of ViewModel Classes?This is the classes that handles data. This is also the class that has INotifyProperty implemented. So it makes sense to have validations here.However, there is nothing stopping you from implementing validations...
16 Jan 2013 by Abhinav S
Both of them work best together, so you should try and build and application that uses Prism and MVVM together.
20 Jan 2013 by Abhinav S
MVVM is not related to modules.This helps you develop screen in a view - view model - format so that you can keep UI decoupled from the code / business logic.The idea behind this is that you can actually style your view without really worrying about whats happening in your code and vice...
22 Apr 2013 by Abhinav S
Model classes act as the placeholder for your data.The viewmodel populates these models.Whenever, there are changes to the model, the viewmodel notifies the UI that it needs to be refreshed due to change in data.
11 Mar 2014 by Abhinav S
TryBinding to the selected items of a ListBox (or another items controls)[^]ListView MultiSelect, MVVM and RoutedCommands[^]MVVM Multiselect Listbox[^]
30 Mar 2014 by Abhinav S
TryValidation in Windows Presentation Foundation[^]WPF Validation[^]Data validation in WPF[^]
29 Jun 2014 by Abhinav S
TryVirtual Paging with Silverlight/WCF Services[^]Introducing An MVVM-Friendly DomainDataSource: The DomainCollectionView[^]
17 Feb 2015 by Abhinav S
No DataContext should not be set in the code-behind.Set the datagrid's source to a collection.
11 Nov 2015 by Abhinav S
Try these links -Cascading Dropdown & Multiselect Option in ListBox Using WPF[^]http://social.technet.microsoft.com/wiki/contents/articles/17946.cascading-comboboxes-in-wpf-using-mvvm.aspx[^]
25 Jan 2013 by Abhishek Pant
How to: Make a Hierarchical treeview binding in WPF[^]Working with Checkboxes in the WPF TreeView[^]WPF Menu using ViewModel - Part 1[^]Simplifying the WPF TreeView by Using the ViewModel Pattern[^]
20 Nov 2010 by Abhishek Sur
C# 5.0 CTP was introduced recently, this article is specally dealing with my own understanding with this realease with few sample applications
30 Dec 2010 by Abhishek Sur
Binding is the most important topic of WPF programming. In this article, I have demonstrated how you could employ DataBinding to ensure that the Presentation logic is separated from the View and also give a simple demonstration on how the DataBinding concept works.
16 Jan 2011 by Abhishek Sur
To get a textbox updated when a property changes its value, implement your property from INotifyPropertyChanged. http://www.abhisheksur.com/2010/05/object-notifiers-using.html[^]You should also note, binding will not work if you explicitly set TextBox.Text somewhere in code behind....
16 Mar 2011 by Abhishek Sur
RegisterName for StoryBoards in WPF (NameScopes)
20 Mar 2011 by Abhishek Sur
WPF inputbindings to bind your key and mouse events directly with your ViewModels
18 Jun 2011 by AbhishekGoenka
Validation Frameworks in .NET Framework 4
8 Mar 2013 by Adil Malik
The best approach is to create an intermediate layer of Services
31 Mar 2014 by Adil Mughal
This article explains how developers can leverage Model-View-ViewModel (MVVM) pattern and .NET Portable Class Libraries (PCL) to create a shared/reusable code for developing apps on Windows Phone and Windows Store platforms.
15 Oct 2014 by adityaswami89
I would suggest you to implement in both : Model and ViewModelAn example is as below:MVVM Sample
28 Jul 2011 by adnama
i have this codepublic partial class ScenarioEditorView : UserControl, IScreenSelectorSubItem, IActionable, INotifyPropertyChanged { ScenarioEditorViewModel viewModel = new ScenarioEditorViewModel(p1);the initialization is out of the method because it is used in...
17 Dec 2021 by adriancs
At the app.config, add the following: Read more about "gcAllowVeryLargeObjects - Microsoft .NET Documentation" and em... yupe, as Dave...
15 Nov 2019 by Ahmad_kelany
Hello everyone, I have a ValidatableBindableBase class that implements INotifyDataErrorInfo interface, and INotifyPropertyChanged interface. The validations depending on data annotations and the custom validations are working fine. The problem is when the text box fails to convert the input...
31 May 2014 by Ahmed Bensaid
An example in WPF ;)http://wpfmembershipadmin.codeplex.com/[^]
3 Sep 2017 by Ahmed Dabas
Where can i found an example that explain using Prism 6 library with entity framework in wpf applications by implementing MVVM Framework What I have tried: i google it , and no result founded
14 Apr 2014 by ahmetkocadogan
Hi. I started to develop an app for windows phone 8. And my app is like this:It has a search page, a textbox at te top. and a longlistselector. when a user enter some text and clicks the app bar button (search button),i'll pass that input to te webservice, and retrieve some data, after that...
31 Dec 2010 by Al Alberto
A series of articles exploring how to develop applications for Windows Azure using Bing Maps.
6 May 2010 by Alan Beasley
Explanation and examples of Additional Templates and Generated Content of a ListBox. Covering Layout, Transitions, and Animation.
24 Jul 2013 by alen_alex_i
I am doing an application in windows phone 8 using MVVMCross.I am not able to navigate from one page to another.Tried using ShowViewModel, but did not work.Could some one help me out in this.Thanks in Advance.
20 Apr 2013 by Alex Define
I have a classic Ado.net entity like Clients and Orders. Also I have a WPF window and using Mvvm architecture. I am new to mvvm and Ado.net so I cant figure out how can get my datagrid(that using one itemsource) show items from clients table and orders table. Its might sound obvious but problem...
19 Jul 2013 by Alexander Dymshyts
I have in my program custom property grid, where all properties are bindable from viewModel. In this property grid there are also 2 buttons - SaveBtn and EditBtn. User edit properties in property grid. When SaveBtn is clicked, all properties must be saved in a database. If user wants to edit...
7 Oct 2013 by Alexander Dymshyts
Set each datacontext of your datagrids to different viewModel.
9 Apr 2014 by Alexander Dymshyts
It's funny, but I cann't find where I am wrong...So I have 2 windows. From the first window I'm calling second on button click event:var window = new WindowButtonClick("Graphic") {DataContext = new GraphicViewModel()};window.ShowDialog();Second window is a window, where I load different...
30 Mar 2017 by Alexey Solonets
In this tip, you will learn how to create a component with configuration properties and bind to them using MVVM.
30 Mar 2017 by Alexey Solonets
Completing Part 1 and making ViewModels isolated
3 Oct 2009 by alexy.shelest
This article will compare and contrast the MVC, MVP, and MVVM, and suggest which pattern to use based on your technology of choice and the problem that you are trying to solve.
10 Feb 2012 by alexy.shelest
This project is a real-time multi-threaded trading application framework developed with WPF / MVVM
2 Mar 2011 by Alireza Loghmani
Hi guys, I'm gonna create profile page for my site. This page includes some 'Partial View' and each part posts some data.My question is: How can I get posted data (strongly typed) from each partial view separately?Something like this:[HttpPost] public ActionResult Home(Model1...
4 Mar 2013 by aliwpf
Hi. try this way : ...
4 Mar 2013 by aliwpf
Hi.this doesn't work completely. if you complete it, please tell me: ...
18 Jan 2017 by Alpha21oct1989
I have two TextBoxes inside my View on which I am trying to implement a simple validation using MVVM design pattern.The issue is even when my ViewModel is implementing Inotification Changed interface and the property is bound tot the text property of the TextBox,on entering text propertyChange...
13 May 2009 by Alphakoda
A first look at commanding in WPF
20 May 2009 by Alphakoda
Provides a clear and simple sample that clearly illustrates MVVM and its usage
10 Sep 2013 by Alvin Ashcraft
The Dew Review – DevExpress WPF Subscription – 2013.1 Release