MVVM: Tutorial from start to finish?

I'm a C#/Windows Forms programmer with more than 5 years experience. I've been investigating WPF using the MVVM (Model-View-ViewModel) design pattern. I have searched the Internet for tutorials. I have even watched the entirety of Jason Dolinger's awesome video. Although I have found many, I have not found one that takes me from start to finish. What I really want is a tutorial t

MVVM:从开始到结束的教程?

我是一名拥有5年以上经验的C#/ Windows Forms程序员。 我一直在使用MVVM(Model-View-ViewModel)设计模式来研究WPF。 我已经在互联网上搜索教程。 我甚至观看了Jason Dolinger的精彩视频。 虽然我找到了很多,但我还没有找到从头到尾都需要我的东西。 我真正想要的是一个不承担任何以前的WPF知识的教程。 什么是你最喜欢的WPF-MVVM教程,帮助你学习? 你的问题似乎真的在问2个问题: 哪里有一些关于WPF的好教程,假

switching views in MVVM wpf

I Know that my problem is a common one but every solution I found is not the one I really need. Here is my problem : I want to be able to switch between different usercontrol in the mainWindow. All the solution I found consist of having a menu in the main window and every button brings the corresponding userControl, like this exemple : https://rachel53461.wordpress.com/2011/12/18/navigation-wit

在MVVM wpf中切换视图

我知道我的问题是一个普遍的问题,但我发现的每一个解决方案都不是我真正需要的解决方案。 这是我的问题:我想能够在mainWindow中的不同usercontrol之间切换。 我找到的所有解决方案都包含在主窗口中有一个菜单,每个按钮都带有相应的userControl,如下所示:https://rachel53461.wordpress.com/2011/12/18/navigation-with-mvvm-2/ 但是我想要的更像是:在开始时,主窗口中有UserControl1。 在userControl1中,会有1个按钮

WPF swtich views using MVVM pattern without Navigation view

I'm building my first WPF app using MVVM pattern. The application begins with a login View that contains a button of login. When i click the login button it executes the ICommand in the LoginViewModel that gets a response from the server if the login succeded. (I'm building a Chat based on WCF and WPF with user credentials) *What I want to achieve is: if the login succeeded, it wi

使用MVVM模式而不使用导航视图的WPF swtich视图

我正在使用MVVM模式构建我的第一个WPF应用程序。 该应用程序以包含登录按钮的登录View开始。 当我单击登录按钮时,它会在LoginViewModel中执行ICommand ,如果登录成功,将从服务器获取响应。 (我正在建立一个基于WCF和WPF的用户凭据) *我想实现的是:如果登录成功,它将切换到注册视图 (我知道它没有任何意义,但它仅用于测试视图切换) 到目前为止,我一直在阅读关于通过按钮导航 。 你的理解并不是我的目标。

Navigate through UserControl with MVVM LIGHT (WPF)

First of all I apologize for my poor english which is not my first language. I'm new in MVVM so my question is probably a very newbie one ;) I'm encountering some issue with switching View in a C# Application using WPF and MVVM LIGHT. I've read a lot of articles but i still can't figured out how to do it in a clean way. So here is my question: What is the best way to achiev

通过MVVM LIGHT(WPF)导航UserControl

首先我为我不好的英语不是第一语言而道歉。 我是MVVM的新手,所以我的问题可能是一个非常新手的问题;) 我在使用WPF和MVVM LIGHT在C#应用程序中切换View时遇到了一些问题。 我读了很多文章,但我仍然无法弄清楚如何以一种干净的方式做到这一点。 所以这里是我的问题:在MainWindows中包含的UserControl之间实现导航的最佳方式是什么,假设: 我有一个ViewModel每个UserControl和一个主Windows。 用户控件之间切换的

WPF MVVM Get Parent from VIEW MODEL

In a MVVM WPF application. How do you set a second windows parent from the ViewModel ? example: view1 -- viewModel1 viewModel1 's command calls: var view2 = new view2 view2.Owner = <----This is the problem area. How do I get view1 as the owner here from the viewModel ? view2.Show() EDIT: See accepted answer below, then read the following edit. I'am using MVVM light -&g

WPF MVVM从VIEW MODEL获取父项

在MVVM WPF应用程序中。 你如何从ViewModel设置第二个窗口父项? 例: view1 - viewModel1 viewModel1的命令调用: var view2 = new view2 view2.Owner = <----这是问题区域。 我如何从viewModel获得view1作为所有者? view2.Show() 编辑: 请参阅下面的接受答案,然后阅读以下编辑。 我使用MVVM光 - > http://mvvmlight.codeplex.com/(真棒顺便说一句) 内置的消息传递系统非常棒。 我现在正在从视

Binding Commands to a Sub Viewmodel

I am trying to Bind a Command to a ViewModel which is a property of another ViewModel. If I bind to a command in the parent viewmodel (ie; the DataContext), it works fine. If I try binding to a viewmodel that's a poperty of my datacontext, it doesn't work (nothing happens). The following code illustrates how things are structured. public class DataViewModel : ViewModelBase { privat

将命令绑定到子视图模型

我正在尝试将命令绑定到ViewModel,该ViewModel是另一个ViewModel的属性。 如果我绑定到父视图模型(即; DataContext)中的命令,它工作正常。 如果我尝试绑定到一个属性为datacontext的视图模型,它不起作用(没有任何反应)。 以下代码说明事物的结构。 public class DataViewModel : ViewModelBase { private ICommand _myCommand; public ICommand MyCommand {get{return _myCommand;}} public DataViewModel()

WPF, MVVM, ICommand, and repositories

I have a WPF application that looks something like this: The viewmodel wraps the model and exposes any attributes relevant to the view via INotifyChanged. The view is also bound to several ICommand objects that handle certain behavior triggered by the view. I have an external ICommand who's sole purpose is to save the model to a database. Everything I've read indicates that neither

WPF,MVVM,ICommand和存储库

我有一个WPF应用程序,看起来像这样: 视图模型包装模型并通过INotifyChanged公开与视图相关的任何属性。 该视图也绑定到几个ICommand对象,该对象处理视图触发的某些行为。 我有一个外部ICommand,其唯一目的是将模型保存到数据库。 我读过的所有内容都表明,视图或视图模型都不应该引用存储库。 这是视图模型之外的命令3的原因。 我的问题是双重的。 首先,这是一个合理的体系结构,其次,将模型实例转移到命令3以便

How to bind ICollectionView to datagrids using MVVM

I am new to WPF and following this link to use code first method to build the example. And the example works. https://msdn.microsoft.com/en-us/data/jj574514.aspx Now, I am trying to change it to follow MVVM. Here is the MainWindow XAML <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="htt

如何使用MVVM将ICollectionView绑定到datagrid

我是WPF的新手,并遵循此链接使用代码优先方法构建示例。 这个例子起作用。 https://msdn.microsoft.com/en-us/data/jj574514.aspx 现在,我试图改变它遵循MVVM。 这是MainWindow XAML <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http:

Binding is not working in WPF MVVM C#

I am working on WPF C#, MVVM Model. I have issue with Save_Button in View. All the things like getter, setter, RelayCommand initialization are working, just nothing happens when I click on 'Save' Buton. So it seems like Binding from View to ViewModel is not working. I am providing here only necessary files of View, ViewModel and Command part. Kindly help. VehicalForm.xaml <Wind

绑定不工作在WPF MVVM C#

我正在研究WPF C#,MVVM模型。 我在View中存在Save_Button问题。 所有的东西,如getter,setter,RelayCommand初始化都在工作,只要点击'Save'Buton就没有任何反应。 所以看起来像从视图绑定到ViewModel不起作用。 我在这里只提供View,ViewModel和Command部分的必要文件。 请帮助。 VehicalForm.xaml <Window x:Class="Seris.VehicalForm" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/present

C# WPF MVVM data validation

I have following WPF-MVVM setup: A view with 2 textfields bound to the properties of the ViewModel with UpdateSourceTrigger=PropertyChanged and a button with a command binding to a relay command (CanExecute, Execute methods) ViewModel which implements INotifyDataErrorInfo with 2 properties annotated with [System.ComponentModel.DataAnnotations.Required]. Property setter call private ViladateP

C#WPF MVVM数据验证

我有以下WPF-MVVM设置: 带有2个文本框的视图绑定到具有UpdateSourceTrigger = PropertyChanged的ViewModel的属性,以及一个带有命令绑定到中继命令(CanExecute,Execute方法)的按钮。 ViewModel实现INotifyDataErrorInfo,其中2个属性用[System.ComponentModel.DataAnnotations.Required]注解。 属性设置器调用私有ViladateProperty方法,该方法将验证结果存储在错误字典中。 HasErrors属性getter检查错误字典以返回适