MVVM的基础是前后台分离,那么就需要把后台的数据与前台的控件绑定。
前台XAML代码:
<Window x:Class="KarliCards.Gui.MainWindow"
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://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:KarliCards.Gui"
mc:Ignorable="d"
Title="MainWindow" Height="175" Width="230">
<Grid Name="grid">
<TextBlock Height="23" Text="Name: " HorizontalAlignment="Left" VerticalAlignment="Top"
Margin="12, 12, 0, 0"/>
<TextBlock Height="23" Text="Ag