Click here to Skip to main content
15,883,910 members
Everything / ViewModel

ViewModel

ViewModel

Great Reads

by dsuryd
SignalR is great for building real-time web functionality. MVVM is great for developing your front-end. What if they can be used together? This tip will show how to do just that, using as example a simple project to do live chart on a web browser.
by Leonid Osmolovski
Techniques for joint execution of a group of commands after single user interface action.
by Dilip Nandakumar
Extending Data Annotations library to support conditional validation in WPF
by Dinesh K.S. Kushwaha
Simple Paged Grid by using knockout js

Latest Articles

by Издислав Издиславов
A simple solution that somehow mimics the real world application, changing it several times, using different UI technlogies and keeping the specific logic the same
by Joost Jens
Describes how to create a Code based view for the Entity Framework
by dsuryd
SignalR is great for building real-time web functionality. MVVM is great for developing your front-end. What if they can be used together? This tip will show how to do just that, using as example a simple project to do live chart on a web browser.
by Dilip Nandakumar
Extending Data Annotations library to support conditional validation in WPF

All Articles

Sort by Score

ViewModel 

15 Jul 2017 by dsuryd
SignalR is great for building real-time web functionality. MVVM is great for developing your front-end. What if they can be used together? This tip will show how to do just that, using as example a simple project to do live chart on a web browser.
16 May 2015 by Leonid Osmolovski
Techniques for joint execution of a group of commands after single user interface action.
16 Dec 2016 by Dilip Nandakumar
Extending Data Annotations library to support conditional validation in WPF
8 May 2014 by sankarsan parida
Add a line after in Index view of Product controller @Html.RenderPartial("myview",Model)
13 Feb 2014 by Sampath Lokuge
For that you have to create ViewModel.Then fill that ViewModel from your domain models data and bind that into your view (i.e. ViewModel to View).What is a ViewModel ?# Allow you to shape multiple entities from one or more data models or sources into a single object# Optimized for...
20 Mar 2015 by Mario Z
Hi, I believe manchanx explained nicely what problem you are facing and how to solve it, but nevertheless I will just add another suggestion that you can use.You can create a main table (like a sort of a container), that would have a single row and in each of that row's cells you would have a...
18 Jan 2014 by Karthik_Mahalingam
You can simulate with this Questions List - main listQuestionsOptions list - secondary list Respose List - secondary listfor example: join 1 ( question list and question option list ) -> it will give 2 rowsjoin 1 results joined with Resonse list -> gives 4 rows as the parent(for...
13 Feb 2014 by jiji2663
i want use multiple model in one view and add records in multiple table from view my db like below image: (i work with vs2012 mvc4 and EF) http://i61.tinypic.com/n17580.png[^]i create four model for each table and class "PreOrder" for repository of allpublic class Orders{ ...
20 Mar 2015 by manchanx
You loop through the items in the Model which are the students of one teacher, respectively. And in that loop you loop through the students. So It can only result in a list with one row.To achieve your tabular presentation you have to output the first student of the first student-list, then...
19 Apr 2015 by Jörgen Andersson
Allow me to plug my own[^] solution
12 May 2016 by Dave Kreskowiak
There's really nothing to help with. It comes down to you reading up on SQL Server security and understanding how it works and how to set it up. There is no way you're going to have someone just give you a blurb in a forum post and it'll magically work.The error is pretty clear. The SQL...
2 Sep 2016 by njammy
Try the answer in this SO post:c# - WPF and Unity - No matching constructor found on type - Stack Overflow[^]
2 Sep 2016 by PureNsanity
For a container to inject constructor parameters the object being initialized needs to be initialized from the container.// Not from container, will not cause any elements to use containervar myWindow = new MyWindow();// From container, will allow elements to be injectedvar...
22 Feb 2019 by OriginalGriff
Byte arrays and Base64 are not the same thing: Base 64 is a "stringified" representation of binary data, which uses a limited set of 64 printable characters (hence the name) to represent the same data in a way that can easily be transferred over text-based links such as HTML. Byte arrays contain...
27 Oct 2019 by OriginalGriff
The ImageSource.FromUri(Uri) Method (Xamarin.Forms)[^] expects a URI class instance as it's single parameter, not a string. Try this: viewModel.Image = ImageSource.FromUri(new URI(string.Format(...)));
20 May 2020 by F-ES Sitecore
If this is per-user data then use the "Session" object. If the data is global then use the System.Web.Caching.Cache object Cache Class (System.Web.Caching) | Microsoft Docs[^]
9 Nov 2021 by DoingWork
Hi Friends I have 2 different user controls i.e. ViewAUserControl.xaml , and ViewBUserControl.xaml . These controls are added dynamically in dynamic tabItems where each tabItem contains any single userControl from availabe 2 UserControls, whom...
11 May 2021 by Estys
Use : @model MultiModels RetourModel is a variable, not a Type Cheers
2 Feb 2022 by Richard Deeming
You are changing an element within an array. That will not raise any "property changed" events, so the UI has no idea that the binding needs to be updated. Try replacing your array with an ObservableCollection: public...
22 Nov 2018 by 204.sharma
Hi, I have created a pagedlist in mvc view. But now when i do pagination my model object properties lost on 2nd page and after pages. I am creating a report page on filter basis. So what is the best process to achieve this ? What I have tried: Here is my Model class public partial class...
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() { ...
2 Jan 2014 by rizwan muhammed khan gouri
hello i hope this works for you.. used instead thisList lstStd = new List() { new Student() { stdId = 103, stdName = "bharath", dept = "CSE" }, new Student() { stdId = 104, stdName = "Hari", dept = "IT" } };useList lstStd = new...
16 Feb 2014 by Justin Shepertycki
I am quite new to WPF and the MVVM pattern so please bare with me. I working on a project for a client and decided to utilize the benefits of WPF in terms of data binding and the declarative approach to UI design. But I'm having a huge issue understanding the relationship between my Views and...
16 Feb 2014 by Justin Shepertycki
A fine gentleman on SO answered my question for me. I did not realize that the child views had their data context set for them when binding to the the ContentPresenter. Once I removed the tag from the ChildUserControl, everything worked like a dream. To view the answer I received click Here [^]
27 Feb 2014 by Dinesh K.S. Kushwaha
7 Mar 2014 by gaarapa
where to find samples using complex models and views in MVC 5?? I need samples using model with jquery and samples of CRUD using three or four models in same view.
7 Mar 2014 by Krunal Rohit
Why don't we first look at the Google[^] ? Example is given here[^]. It's not what you want, but still it is less that what you want.-KR
7 Mar 2014 by Peter Leow
Check this out: Getting Started with ASP.NET MVC 5[^]
18 Mar 2014 by rthompzz
Here's my viewmodel. window.makeApp.makeViewModel = (function (ko, datacontext) { //Data var self = this; self.makeLists = ko.observableArray(); self.error = ko.observable(); //Operations //Load initial state from the server, convert it to make instances,...
21 May 2014 by Morore_Charles_007
HiI have used a view model on my project namespace KCM.ViewModel{ public class KCMViewModel { public CrisisCallerInfo CrisisCallerInfo { get; set; } public CrisisComments CrisisComments { get; set; } public CrisisDeceasedInfo CrisisDeceasedInfo { get;...
15 Jun 2014 by JO Hyeong-Ryeol
An introduction to the WatchableObject that is a base class to implement the INotifyPropertyChanged interface.
17 Jul 2014 by Jagat M
Should the binding in the user control for the text box be ContainerData instead of UC1?
10 Oct 2014 by TNJS82
Sir,I add a .dll to a project and for using it in my view i add a namespace in web.Config(in view folder) but after adding namespace i am getting an error in all my .cshtml files in @model line.what is wrong..my login.cshtml@model myStore.Models.LoginModel@using myStore@using...
11 Oct 2014 by Suraj Sahoo | Coding Passion
Please check here[^]Please check the solution in the above link, This may help.If not, respond back with comments.All the best.Thanks:)
29 Nov 2014 by PuchuKing33
Hello everyoneI am new to coding in C#, and i am trying to correctly code in the MVVM pattern using WPF with my MySQL database.I have a form called characters with a combobox called cb_Names. The idea is ones the form is loaded the combobox gets populated with the names of the characters...
20 Mar 2015 by Anoob Aliyar
public class ClassRoom{ public string TeacherName { get; set; } public List StudentNames { get; set; }}I want to display the below mentioned ViewModel dynamic data to my MVC view (html table) in such a way that (only pseudo view) Expected...
19 Apr 2015 by Rana Waqas
if i am not wrong is this a solution that you were tryingDataSet ds = new DataSet(); DataTable dt = new DataTable(); dt.Columns.Add("Name"); dt.Rows.Add("Affan"); dt.Rows.Add("osama"); dt.Rows.Add("faraz"); ...
19 Apr 2015 by EMNA AYADI
how can i convert list of view models to data table to print it in pdf later ? i have error in this line : values[i] = Props[i].GetValue(item, null).ToString();cant convert it ! public ActionResult detailsoperation(OperationViewModel operationvm, CategorieViewModel categories,...
19 Apr 2015 by Maciej Los
Solution1 by Jörgen Andersson[^] is very good. In addition to it, i'd suggest to read this: How to: Implement CopyToDataTable Where the Generic Type T Is Not a DataRow[^]
25 Jun 2015 by ParniM
Hi everybody,I just want to get a clicked element name in the ViewModel code.Basically, I generate several rectangles programmatically ...
7 Oct 2015 by vini vasundharan
i have the following ViewModel and I can't find a way to access the variables to perform a select operation public class ViewOptionValues { public Option Option { get; set; } public IEnumerable Values { get; set; } } public class...
10 Oct 2015 by vini vasundharan
I have the following ViewModel and the controller to View the set in the ViewModel. I am not able to get the values from the nested collection in the ViewModel. But I can see the values are being populated in the right way in the parent class.ViewModelpublic class Option_OptionValues ...
10 Oct 2015 by Nosfa
I have this function to return a view Function mostrar(cor As String, alinea As Char) As ActionResult ViewBag.cor = cor ViewBag.alinea = alinea Return View() End Functionthis is the view@Code ViewBag.Title = "mostrar" End...
10 Oct 2015 by F-ES Sitecore
Calling the code as a function isn't going to generate html. If that's what you want to do then google "asp.net get html from controller programmatically" and you'll find examples of how to get the rendered html.
10 Oct 2015 by Zoltán Zörgő
Use "Reply", so I get notified about your message. I got here by accident, and I saw your comment.To be short: you can't make an ajax call and expect a "regular" effect. You either use ajax to talk to the backend or do regular POSTs or GETs.When designing ajax backend call you can decide...
8 Nov 2015 by Member 10999473
when the multiple users using same mvc application request the same method and the coming data from db is binding to the viewmodel the data is exchanging for multiple user .can i use veiwdata for display the data in view in case multiple users ?view data varies value based on multiple...
8 Nov 2015 by Krunal Rohit
For every request new instance is generated, meaning - for multiple users multiple instances are created and web server does that as it is multi-threaded.You can user viewdata to display the data.-KR
7 Jan 2016 by F-ES Sitecore
If you want to bind to a collection you can't use "foreach", you have to use "for" and access the elements via an indexrazor - ASP.NET MVC 4 - for loop posts model collection properties but foreach does not - Stack Overflow[^]
16 Mar 2016 by arslan afzal bhatti
i am using view model to upload multiple videos but the videos are not uploading. before using the view model code working fine but now when i click on upload button and debug then the video object is null here is my code of controller using Microsoft.AspNet.Identity;using...
12 May 2016 by Deepak Kanswal Sharma
I'm New to MVC Application . My problem is while I'm trying to connect to Sql Server2008 . This is giving me the error :- Cannot open database "rsbenggmvc.Models.RsbEnggContext" requested by the login. The login failed.Login failed for user 'DEEPAK-PC\DEEPAK'.Project Name :-...
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...
18 Jan 2017 by eddieangel
Have you put a breakpoint in your setter to see if that is even being fired? Check that and also change your binding path to TwoWay binding to see if that is the issue.
8 Feb 2017 by Karthik_Mahalingam
refer this example and build it.Location and Age columns are empty and 0 values respectively.
23 Feb 2017 by Sabyasachi Mukherjee
I have a WPF app where I am trying to create an on-screen keyboard as a Usercontrol.Here is the XAML for the design:
18 Apr 2017 by Member 13021319
I have MVC framework User Table and my own Community Table. I also have a relationship CommunityUser table. I am virtually connecting CommunityUser table with community Table. Here is my Community class public class Community { [Key] public int CommunityID { get; set; } ...
23 Nov 2017 by ujjwal uniyal
I have 3 tables subject , topic and sub topic. topic has subjectID as foreign key while subtopic has topic id as foreign key. I am using EF6 DB First to generate model classes. I have created the Create view for subject which works fine. Now i want to create a create view for Topic. after...
10 Dec 2017 by Member 13507572
I am trying to pass valued from my database to a shared view but I keep getting this error (Please note I am very new to MVC, so I dont understand the error I get) - The model item passed into the dictionary is of type...
1 Apr 2018 by #realJSOP
Find a hex editor, open the file with it, and see if you can determine how it's laid out.Chances are few if any of us play the game, so we don't have an example of the file to do it for you.
27 Oct 2019 by Jassim Rahma
Hi, I am trying to store image from URL into an image viewmodal but getting: the best overloaded method has some invalid arguments What I have tried: Here is what is m trying: viewModel.Image = ImageSource.FromUri(string.Format("https://www.domain.com/gallery/channels/{0}/{1}.png",...
5 May 2020 by Todor Iliev
So I'm new to C# and i've been stuck on this for hours. I tried multiple passings (ViewBag, ViewData and also as a parameter). In my View it says it gets a NullPointerException at the foreach loop. What I have tried: this is my Model: ...
5 May 2020 by ZurdoDev
As mentioned in comments, after checking out structure of site found that there was an Index view causing issue.
11 May 2020 by Todor Iliev
Right now I am successfully passing my data from the View to the Controller. My Controller is connected to two Views. One of which is the one i want to use for my user input and second one where i Display the user input in a table. What I have...
11 May 2020 by Richard Deeming
Every time you make a request, a new instance of your controller is created. It processes the request and generates a response, and then that instance is thrown away, along with all of its fields. The item you add to the bookings field in your...
20 May 2020 by Todor Iliev
My question is, is there a way to pass data from one controller to another, more specifically cache-data, and if yes how ? I have built a system that can create bookings and save them in a cache so i can display them in my view. Now I have a...
19 Jul 2020 by CDA the Programmer
I'm developing a Java Spring Boot Web App and am currently trying to implement a "Forgot Password?" feature. As part of the feature, the user clicks on "Forgot Password?" link which takes them to forgotPassword.jsp. There, the user must enter...
18 Dec 2020 by Member 15024312
I have a collection List Adapters in my view model. Equivalent to the collection I want to have List.Count() number of radio buttons with their names .and by default I should have Adapters[0] as selected (IsChecked) radio button on launch of the...
18 Dec 2020 by Ankush Khurana
I am not sure if I understood your question correctly. It would have been good if you had shared your code. However in order to generate items dynamically, use ObservableCollection and bind it to radiobutton control in xaml.
19 Dec 2020 by khalid4775
Hi .... Iam tring to insert data to database table but i need it check befor insert if the inserted data is Exists in database table iam getting this error : CS0120 An object reference is required for the non-static field, method, or property...
19 Dec 2020 by Gerry Schmitz
Just make InsertVisitsTypesParamerter static; it has no "non-local" references: public static SaveResult InsertVisitsTypesParamerter( etc. (Your response to Richard was a non-answer; a repeat of the problem)
11 May 2021 by LSB71
Quote: Good morning all, I'm crashing in front of this error message (Error: CS0246: Type or namespace name 'ModelReturn' could not be found (are you missing a using directive or assembly reference *?)): Let me explain : - Basically in my view...
9 Nov 2021 by pszyjaciel
In the ViewAUserControl.xaml: xmlns:local="clr-namespace:WpfPractice.ViewModel" In the ViewBUserControl.xaml: ...
27 Jan 2022 by materialAres
I have to do this project of classified ads for Coursera. Essentially every user can post, update and delete advertisements. The problem is that even if the objects are correctly stored (I checked tables and objects via admin and manually with...
3 Feb 2022 by Roy Mustang 2022
I am trying to change button's color when it is clicked. But it is not changing color. Here is my code. What I have tried: private SolidColorBrush[] _btnBrush; public SolidColorBrush[] btnBrush { get { ...
23 Feb 2017 by Graeme_Grant
Quote:according to most of the opinions online, giving a Usercontrol a viewmodel of its own is an extremely bad ideaThis is a new one for me. Popular opinion is actually the complete opposite! To me, it is personal preference or usage-specific. For example, I may have a complex entry form...
16 Dec 2014 by #realJSOP
Eliminate the tedium of generating model and viewmodel classes for your WPF projects, and save a butt-load of time in the process.
11 Aug 2015 by Leonid Osmolovski
Techniques for MultiBinding based ViewModel - ViewModel communications in the MVVM pattern.
6 Feb 2015 by ogomerub
ViewModel base for all ViewModels. Validation system with DataAnnotations and IDataErrorInfo
3 Jun 2019 by Издислав Издиславов
A simple solution that somehow mimics the real world application, changing it several times, using different UI technlogies and keeping the specific logic the same
9 Oct 2018 by Joost Jens
Describes how to create a Code based view for the Entity Framework
18 Jan 2014 by AlexHarmes
I have a ViewModel; public class GetQuestionViewModel { public IEnumerable Questions { get; set; } public IEnumerable QuestionOptions { get; set; } public int Id { get; set; } public Nullable Options { get; set; } ...
2 Sep 2016 by mmiklauz
Hi,I have this code in my .xaml file: It works perfectly when ViewModel has a constructor with no parametars, but when I set ViewModel constructor with parametars it won't...
1 Apr 2018 by Member 13755707
I need to know how to make a model viewer program that can view files from the fear game like the Model00p There is no tools out there that I can find is there a api that I can use to make a program like this thanks in advance What I have tried: I have tried the fear public tools and they can...
26 Jan 2016 by Hugo Gonzalez Olaya
To executing of asynchronous task, we are going to use: 1. Task-based asynchronous pattern (TAP) which it is based on the types Task and Task . 2. MVVM pattern for execution of an operation. 3. Progress bars indicating the progress of task and subtask
19 Mar 2014 by Justin Shepertycki
Finally found the culprit!!At my work, our desktops are hosted on a network share. I had brought two applications I was working on from home and dropped the application files temporarily on the desktop to make some quick minor changes. Turns out there is a bug in the WPF Designer where the...
9 May 2014 by mgsdew
I want create a partial view and merge it with main view. But, something is going wrong with my code. Can anyone explain it for me by seeing my given code:-In my Product Controller I write those code for upload File/Image : [HttpPost][ValidateAntiForgeryToken] public ActionResult...
17 Jul 2014 by Member 10558493
Currently, I have a working C# WPF application consisting of several User Controls. One of the User Controls needs data from this MainWindow to properly display additional information and process itself. (For now, it would be satisfactory just to pass a string between the MainWindow and the User...
7 Jan 2016 by Member 12184709
Hello,I would like to get Unit_Price and Quantity to ActionResult Index.any help appreciatedModel Product[Table("Product")]public class Product{ public Product() { ProductyDetails = new HashSet(); } [Key]//[Required] public int...
1 Jan 2014 by Dominic Abraham
HiI made a small change in your source. Please check. public class StudentController : Controller { // // GET: /Student/ public ActionResult Student() { StudentList stdlist = new StudentList(); List lstStd =...
31 Dec 2013 by Vinay Jade
use following syntax:@using (Html.BeginForm(Action name,controller name))eg in your code@using (Html.BeginForm(student,student))Add breakpoints to codebehind to check flow of the execution
19 Mar 2014 by Justin Shepertycki
I know this question has been asked multiple times, and I've gone through them all. Hopefully I didn't just miss something in the previous answers, but I'm stumped.My application was working fine yesterday, but today I booted it up and now none of my file references, including ViewModels or...
19 Mar 2014 by Sergey Alexandrovich Kryukov
Please see my comment to your "Solution 1". This is not a solution at all. Actually, referencing the types defined in the same project is not a problem at all. It is not easy, it is very easy. To start, start adding the xmlns attribute to your top XAML element by typing "xmlns:". The...
19 Apr 2015 by EMNA AYADI
i couldn't bind session with data set ,so that i think that data table is the only solution.How can i generate dataTable from Session that i have created in the viewmoddel?
8 Feb 2017 by Member 12583662
Hi I have something likeViewData["getServices"] = (from p in dbObj.gen_crm_consolidate where p.service_id == sID && p.pdate >= sDate.Date && p.pdate
25 May 2017 by ddgjgj
This is the view : @model Northwind.Employee @{ ViewBag.Title = "Details"; Layout = "~/Views/Shared/MasterDetailsLayoutPage.cshtml"; } Details Employee @Html.DisplayNameFor(model =>...
12 Sep 2017 by Member 2799988
I am not able to mock the navigationcontext using moq framework. Can anyone help on this Constructor -------------- public CreateQuestionsViewModel(IEventAggregator eventAggregator, IUnityContainer unityContainer) : base(eventAggregator, unityContainer) { ...
22 Feb 2019 by Codes DeCodes
In my MVC project, I am using viewModel that has property of type byte[]. I am using byte[] to hold image file so that this file can be passed to model. My view is strongly typed view. The problem is whenever I click on submit button to send control to controller, I am getting exception " The...
7 Apr 2021 by John Song 2021
Hello everyone! So, basically how can you make all the model instances updated on a daily basis in Django? Right now, I have a model that has each of my students' information. I want to update each of my students information everyday, so that the...