MVVM(Model-View-ViewModel)是一种软件架构模式,用于实现用户界面(UI)和业务逻辑之间的分离。 view 和 model 之间没有直接的关系,通过 viewModel 来完成数据双向绑定。

xaml界面(输入框与StudentViewModel相关属性绑定)
<Control:MetroWindow.Resources>
<Style x:Key="FromLabel" TargetType="{x:Type Label}">
<Setter Property="FontSize" Value="20"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="Margin" Value="5"></Setter>
</Style>
<Style x:Key="FromTextBox" TargetType="{x:Type TextBox}">
<Setter Property="FontSize" Value="20"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="Margin" Value="5"></Setter>
<Setter Property="Width" Value="200"></Setter>
</Style>
</Control:MetroWindow.Resources>
<Grid>
<Grid.R

本文详细描述了MVVM架构如何在XAML界面中实现用户界面和业务逻辑分离,通过实例展示了如何在StudentViewModel和XAML控件间进行数据双向绑定,以及MainViewModel和StudentViewModel的交互过程。
最低0.47元/天 解锁文章
593

被折叠的 条评论
为什么被折叠?



