我应该使用mvvm用于WPF吗? [英] Should I use mvvm for WPF?

查看:446
本文介绍了我应该使用mvvm用于WPF吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MVVM很糟糕。

这就像没有javascript的HTML。

It's like HTML without javascript.

我应该使用XML语法更改模型中的视图。

I should use XML syntax to change the View from Model.

<DataGrid>
        <DataGrid.CellStyle>
            <Style TargetType="DataGridCell">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding MyViewModel.Modified}"
                                 Value="True">
                        <Setter Property="Background" Value="Yellow"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </DataGrid.CellStyle>
</DataGrid>

这是什么?这个怎么样? 

What is this? And How about this? 

if(mode.Modified)

grid.Background = Color.Yellow;

更简单。

XML不是编程语言。我想MS不知道那个。

XML is not programming language. I think MS dosen't know that.

它让程序员很难开发Windows应用程序。

It makes programmers hard to develop Windows app.

我认为winform比WPF好得多,因为winform总是使用C#。

I think winform is much better than WPF because winform always use C#.

推荐答案

你根本不需要使用MVVM。这取决于你,我喜欢WPF,XAML和所有绑定,它使我的工作更容易。它更容易维护。它自动更新UI我做了很多工作。维护一个更大的项目更容易。 
我的意思是如果他们习惯了它可以使用记事本并且可以使用MSBuild。这取决于你。我喜欢工具和新设置。一旦你学会了,你就会明白更多。

You do not have to use MVVM at all. It is up to you, I love WPF, XAML and all the bindings, it makes my job easier. It is easier to maintain. It updates the UI automatically and a lot of work is done for me. It is easier to maintain on a bigger project.  I mean one can use notepad if they are used to it and can use MSBuild. It is up to you. I like the tools and new set up. Once you learn it , you will understand more.

例如,在你的代码中,你必须检查以确保Thread是UI线程(只能通过UI线程访问网格,因此您将应用程序限制为单个线程?)

As an example, in your code, you have to check to make sure that the Thread is UI Thread (grid can ONLY be accessed through UI Thread, so you are limiting your application to single Thread?)

底线是不是无论如何处理XAML,即使在记事本中也可以手动编码。它是可行的。为它而努力,给你更多力量!

Bottom line is you do not HAVE TO deal with XAML, you can code all by hand, even in notepad. It is do-able. Go for it, more power to you!

MVVM将视图分开,所以明天如果您决定使用语音命令,则不必更改其他2个图层,只需将其连接到语音表示层。

MVVM separates the View, so tomorrow if you decide to use Voice Commands, , you do not have to change the 2 other layers, you just hook it up to a Voice presentation layer.


这篇关于我应该使用mvvm用于WPF吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆