You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
<Window x:Class= "MVVMDemo.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:MVVMDemo"
mc:Ignorable= "d"
Title= "MainWindow" Height= "450" Width= "800" >
<Window.DataContext >
<!-- // 有很多中绑定方式, 这里选择了UI代码中绑定// -->
<local:MainViewModel />
</Window.DataContext>
<Grid >
<StackPanel Orientation= "Vertical"
HorizontalAlignment= "Center"
VerticalAlignment= "Center" >
<StackPanel Orientation= "Horizontal"
Margin= "2" >
<Label Content= "Origin Content: "
FontSize= "20"
VerticalAlignment= "Center"
HorizontalAlignment= "Center" />
<TextBox Text= "{Binding TextContent, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
TextWrapping= "Wrap"
MinWidth= "400"
MaxWidth= "600"
FontSize= "20"
Padding= "4" />
</StackPanel>
<StackPanel Orientation= "Horizontal"
Margin= "2" >
<Label Content= "Sync Content: "
FontSize= "20"
VerticalAlignment= "Center"
HorizontalAlignment= "Center" />
<TextBlock Text= "{Binding TextContent}"
TextWrapping= "Wrap"
MinWidth= "400"
MaxWidth= "600"
FontSize= "20"
Padding= "4" />
</StackPanel>
<!-- // CommandParameter: 绑定对象到BtnCmd上 // -->
<Button Content= "Reset"
Command= "{Binding BtnCmd}"
CommandParameter= "{Binding RelativeSource={RelativeSource AncestorType=Window}}"
FontSize= "30" />
</StackPanel>
</Grid>
</Window>