首页 > 编程语言 >学习wpf笔记3 MVVM模式——【转】C# WPF简单的MVVM模式事例

学习wpf笔记3 MVVM模式——【转】C# WPF简单的MVVM模式事例

时间:2022-11-18 11:35:11浏览次数:65  
标签:gt MVVM C# System 模式 lt using public

一、前言

WPF中使用MVVM模式开发有诸如以下优点:
1.结构清晰明朗,上手成本低,一个新人也能快速的定位自己需要改动代码的位置。
2.耦合度低,更改WPF控件不影响数据结构,更改代码成本低。
3.可重用性高,比如一个处理逻辑放到ViewModel模块中,其他界面如果要用掉直接调用即可。
当然并不是所有的项目都去使用MVVM开发,一些简单的我们也可以按照正常的开发。
本次例子参考“刘铁猛”老师的WPF视频教程,大家有兴趣可以去观看。
话不多说,开始写Demo。

二、需要实现目的

  1. 点击相加按钮实现数字一和数字二想加的结果:
  2. 点击保存按钮弹出文件保存窗口(只是简单的弹出窗口,并非实现正在的保存)
    在这里插入图片描述

三、编写SampleMvvmDemo

①实现思路

这是一个很简单的Demo,我们的第一反应就是,不就是一个界面上有两个Button按钮。
一个名为:“保存”,一个名为:“相加”。然后给两个Button分别添加两个Click事件。
点保存按钮的时候弹出文件保存框:

SaveFileDialog dlg = new SaveFileDialog();
dlg.ShowDialog();
  • 1
  • 2

点击相加按钮的时候计算Textbox1(数字一)与TextBox2(数字二)输入的值想加的结果然后赋值给TextBox3(结果为):

textBox3.Text = (double.Parse(textBox1.Text)+ double.Parse(textBox2.Text)).ToString();
  • 1

其实这样没错,但是现在我把界面改变了,把保存按钮换成了保存菜单,把三个Textbox换成了三个Slider,前面两个Slider想加的结果显示到第三个Slider上面。例如这样:
在这里插入图片描述

这个时候我们就需要在后台把之前的Click事件里面的代码进行修改,随着需求的不断变更,开发成本还是比较高的,这个是我们用MVVM模式来实现一下这些效果。

②MVVM实现

首先我们创建一个SampleMvvmDemo的WPF应用项目,然后在项目中添加两个文件夹
一个为Command用来触发空间的Command
一个为ViewModels用来处理页面上的数据或者控件逻辑。
这个是项目结构,简单的MVVM框架
在这里插入图片描述
然后我们在ViewModels中添加两个类
第一个为消息通知类(NotificationObject.cs),用来告诉页面值发生了变化,需要触发逻辑

using System.ComponentModel;

namespace SampleMvvmDemo.ViewModels
{
class NotificationObject : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

    <span class="token keyword">public</span> <span class="token return-type class-name"><span class="token keyword">void</span></span> <span class="token function">RaisePropertyChanged</span><span class="token punctuation">(</span><span class="token class-name"><span class="token keyword">string</span></span> propertyName<span class="token punctuation">)</span>
    <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>PropertyChanged <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span>
        <span class="token punctuation">{<!-- --></span>
            PropertyChanged<span class="token punctuation">.</span><span class="token function">Invoke</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token constructor-invocation class-name">PropertyChangedEventArgs</span><span class="token punctuation">(</span>propertyName<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

在这里插入图片描述
第二为窗体的交互逻辑类(MainWindowViewModel.cs),看名字也能得知这是界面与数据之间逻辑交互的地方。

using Microsoft.Win32;
using SampleMvvmDemo.Commands;
using System;

namespace SampleMvvmDemo.ViewModels
{
class MainWindowViewModel : NotificationObject
{
public MainWindowViewModel()
{
AddCommand = new DelegateCommand();
AddCommand.ExecuteAction = new Action<object>(Add);
SaveCommand = new DelegateCommand();
SaveCommand.ExecuteAction = new Action<object>(Save);
}

    <span class="token keyword">private</span> <span class="token class-name"><span class="token keyword">double</span></span> input1<span class="token punctuation">;</span>

    <span class="token keyword">public</span> <span class="token return-type class-name"><span class="token keyword">double</span></span> Input1
    <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">get</span> <span class="token punctuation">{<!-- --></span> <span class="token keyword">return</span> input1<span class="token punctuation">;</span> <span class="token punctuation">}</span>
        <span class="token keyword">set</span>
        <span class="token punctuation">{<!-- --></span>
            input1 <span class="token operator">=</span> <span class="token keyword">value</span><span class="token punctuation">;</span>
            <span class="token function">RaisePropertyChanged</span><span class="token punctuation">(</span><span class="token string">"Input1"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">private</span> <span class="token class-name"><span class="token keyword">double</span></span> input2<span class="token punctuation">;</span>

    <span class="token keyword">public</span> <span class="token return-type class-name"><span class="token keyword">double</span></span> Input2
    <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">get</span> <span class="token punctuation">{<!-- --></span> <span class="token keyword">return</span> input2<span class="token punctuation">;</span> <span class="token punctuation">}</span>
        <span class="token keyword">set</span>
        <span class="token punctuation">{<!-- --></span>
            input2 <span class="token operator">=</span> <span class="token keyword">value</span><span class="token punctuation">;</span>
            <span class="token function">RaisePropertyChanged</span><span class="token punctuation">(</span><span class="token string">"Input2"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">private</span> <span class="token class-name"><span class="token keyword">double</span></span> resulte<span class="token punctuation">;</span>

    <span class="token keyword">public</span> <span class="token return-type class-name"><span class="token keyword">double</span></span> Result
    <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">get</span> <span class="token punctuation">{<!-- --></span> <span class="token keyword">return</span> resulte<span class="token punctuation">;</span> <span class="token punctuation">}</span>
        <span class="token keyword">set</span>
        <span class="token punctuation">{<!-- --></span>
            resulte <span class="token operator">=</span> <span class="token keyword">value</span><span class="token punctuation">;</span>
            <span class="token function">RaisePropertyChanged</span><span class="token punctuation">(</span><span class="token string">"Result"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">public</span> <span class="token return-type class-name">DelegateCommand</span> AddCommand <span class="token punctuation">{<!-- --></span> <span class="token keyword">get</span><span class="token punctuation">;</span> <span class="token keyword">set</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
    <span class="token keyword">public</span> <span class="token return-type class-name">DelegateCommand</span> SaveCommand <span class="token punctuation">{<!-- --></span> <span class="token keyword">get</span><span class="token punctuation">;</span> <span class="token keyword">set</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
    <span class="token keyword">private</span> <span class="token return-type class-name"><span class="token keyword">void</span></span> <span class="token function">Save</span><span class="token punctuation">(</span><span class="token class-name"><span class="token keyword">object</span></span> parameter<span class="token punctuation">)</span>
    <span class="token punctuation">{<!-- --></span>
        <span class="token class-name">SaveFileDialog</span> dlg <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token constructor-invocation class-name">SaveFileDialog</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        dlg<span class="token punctuation">.</span><span class="token function">ShowDialog</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">private</span> <span class="token return-type class-name"><span class="token keyword">void</span></span> <span class="token function">Add</span><span class="token punctuation">(</span><span class="token class-name"><span class="token keyword">object</span></span> parameter<span class="token punctuation">)</span>
    <span class="token punctuation">{<!-- --></span>
        Result <span class="token operator">=</span> input1 <span class="token operator">+</span> input2<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>



<span class="token punctuation">}</span>

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67

在这里插入图片描述

写到这里的时候,会有些地方报错,这是因为我们Command还没有写方法
我们在Command文件夹中添加一个DelegateCommand.cs类,代码如下:

using System;
using System.Windows.Input;

namespace SampleMvvmDemo.Commands
{
class DelegateCommand : ICommand
{
public event EventHandler CanExecuteChanged;

    <span class="token keyword">public</span> <span class="token return-type class-name"><span class="token keyword">bool</span></span> <span class="token function">CanExecute</span><span class="token punctuation">(</span><span class="token class-name"><span class="token keyword">object</span></span> parameter<span class="token punctuation">)</span>
    <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>CanExcuteFunc <span class="token operator">==</span> <span class="token keyword">null</span><span class="token punctuation">)</span>
        <span class="token punctuation">{<!-- --></span>
            <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> <span class="token function">CanExcuteFunc</span><span class="token punctuation">(</span>parameter<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token return-type class-name"><span class="token keyword">void</span></span> <span class="token function">Execute</span><span class="token punctuation">(</span><span class="token class-name"><span class="token keyword">object</span></span> parameter<span class="token punctuation">)</span>
    <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>ExecuteAction <span class="token operator">==</span> <span class="token keyword">null</span><span class="token punctuation">)</span>
        <span class="token punctuation">{<!-- --></span>
            <span class="token keyword">return</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token function">ExecuteAction</span><span class="token punctuation">(</span>parameter<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token return-type class-name">Action<span class="token punctuation">&lt;</span><span class="token keyword">object</span><span class="token punctuation">&gt;</span></span> ExecuteAction <span class="token punctuation">{<!-- --></span> <span class="token keyword">get</span><span class="token punctuation">;</span> <span class="token keyword">set</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
    <span class="token keyword">public</span> <span class="token return-type class-name">Func<span class="token punctuation">&lt;</span><span class="token keyword">object</span><span class="token punctuation">,</span> <span class="token keyword">bool</span><span class="token punctuation">&gt;</span></span> CanExcuteFunc <span class="token punctuation">{<!-- --></span> <span class="token keyword">get</span><span class="token punctuation">;</span> <span class="token keyword">set</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32

在这里插入图片描述
至此,我们已经把MVVM中的VM实现了。
接下来我们把界面设计好也就是MVVM中的V。
界面代码:

<Window x:Class="SampleMvvmDemo.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:SampleMvvmDemo"
        mc:Ignorable="d"
        Title="MainWindow" Height="263" Width="300" WindowStartupLocation="CenterScreen">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Menu>
            <MenuItem Header="菜单">
                <MenuItem Header="保存" Command="{Binding SaveCommand}"/>
            </MenuItem>
        </Menu>
        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <StackPanel Grid.Row="0" Orientation="Horizontal" >
                <TextBlock Text="数字一:" VerticalAlignment="Center"/>
                <TextBox x:Name="textBox1"  Width="242" Background="LightBlue" FontSize="24" Margin="5" Text="{Binding Input1}"/>
            </StackPanel>
            <StackPanel Grid.Row="1" Orientation="Horizontal">
                <TextBlock Text="数字二:" VerticalAlignment="Center"/>
                <TextBox x:Name="textBox2" Width="242" Background="LightBlue" FontSize="24" Margin="5" Text="{Binding Input2}"/>
            </StackPanel>
            <StackPanel Grid.Row="2" Orientation="Horizontal">
                <TextBlock Text="结果为:" VerticalAlignment="Center"/>
                <TextBox x:Name="textBox3" Width="242" Background="LightGreen" FontSize="24" Margin="5" Text="{Binding Result}"/>
            </StackPanel>
            <Button x:Name="btnAdd" Content="相加" Grid.Row="3" Width="120" Height="40" Command="{Binding AddCommand}"/>
        </Grid>
    </Grid>
</Window>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42

在这里插入图片描述

界面后台代码:

using SampleMvvmDemo.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SampleMvvmDemo
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = new MainWindowViewModel();

    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

在这里插入图片描述
我们可以看到View的后台代码非常的简洁。
即使像刚刚提到的改变控件的需求,我们也无需动后台的代码,只需要改变控件,重新绑定即可。
例如改成所说的Slider 与菜单保存

<Window x:Class="SampleMvvmDemo.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:SampleMvvmDemo"
        mc:Ignorable="d"
        Title="MainWindow" Height="263" Width="300" WindowStartupLocation="CenterScreen">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Menu>
            <MenuItem Header="菜单">
                <MenuItem Header="保存" Command="{Binding SaveCommand}"/>
            </MenuItem>
    <span class="token operator">&lt;</span><span class="token operator">/</span>Menu<span class="token operator">&gt;</span>
    <span class="token operator">&lt;</span>Grid Grid<span class="token punctuation">.</span>Row<span class="token operator">=</span><span class="token string">"1"</span><span class="token operator">&gt;</span>
        <span class="token operator">&lt;</span>Grid<span class="token punctuation">.</span>RowDefinitions<span class="token operator">&gt;</span>
            <span class="token operator">&lt;</span><span class="token class-name">RowDefinition</span> Height<span class="token operator">=</span><span class="token string">"Auto"</span><span class="token operator">/</span><span class="token operator">&gt;</span>
            <span class="token operator">&lt;</span><span class="token class-name">RowDefinition</span> Height<span class="token operator">=</span><span class="token string">"Auto"</span><span class="token operator">/</span><span class="token operator">&gt;</span>
            <span class="token operator">&lt;</span><span class="token class-name">RowDefinition</span> Height<span class="token operator">=</span><span class="token string">"Auto"</span><span class="token operator">/</span><span class="token operator">&gt;</span>
            <span class="token operator">&lt;</span><span class="token class-name">RowDefinition</span> Height<span class="token operator">=</span><span class="token string">"*"</span><span class="token operator">/</span><span class="token operator">&gt;</span>
        <span class="token operator">&lt;</span><span class="token operator">/</span>Grid<span class="token punctuation">.</span>RowDefinitions<span class="token operator">&gt;</span>
        <span class="token operator">&lt;</span>StackPanel Grid<span class="token punctuation">.</span>Row<span class="token operator">=</span><span class="token string">"0"</span> Orientation<span class="token operator">=</span><span class="token string">"Horizontal"</span> <span class="token operator">&gt;</span>
            <span class="token operator">&lt;</span><span class="token class-name">TextBlock</span> Text<span class="token operator">=</span><span class="token string">"数字一:"</span> VerticalAlignment<span class="token operator">=</span><span class="token string">"Center"</span><span class="token operator">/</span><span class="token operator">&gt;</span>
            <span class="token operator">&lt;</span><span class="token class-name">Slider</span> x<span class="token punctuation">:</span>Name<span class="token operator">=</span><span class="token string">"textBox1"</span>  Width<span class="token operator">=</span><span class="token string">"242"</span> Background<span class="token operator">=</span><span class="token string">"LightBlue"</span> FontSize<span class="token operator">=</span><span class="token string">"24"</span> Margin<span class="token operator">=</span><span class="token string">"5"</span> Value<span class="token operator">=</span><span class="token string">"{Binding Input1}"</span><span class="token operator">/</span><span class="token operator">&gt;</span>
        <span class="token operator">&lt;</span><span class="token operator">/</span>StackPanel<span class="token operator">&gt;</span>
        <span class="token operator">&lt;</span>StackPanel Grid<span class="token punctuation">.</span>Row<span class="token operator">=</span><span class="token string">"1"</span> Orientation<span class="token operator">=</span><span class="token string">"Horizontal"</span><span class="token operator">&gt;</span>
            <span class="token operator">&lt;</span><span class="token class-name">TextBlock</span> Text<span class="token operator">=</span><span class="token string">"数字二:"</span> VerticalAlignment<span class="token operator">=</span><span class="token string">"Center"</span><span class="token operator">/</span><span class="token operator">&gt;</span>
            <span class="token operator">&lt;</span><span class="token class-name">Slider</span> x<span class="token punctuation">:</span>Name<span class="token operator">=</span><span class="token string">"textBox2"</span> Width<span class="token operator">=</span><span class="token string">"242"</span> Background<span class="token operator">=</span><span class="token string">"LightBlue"</span> FontSize<span class="token operator">=</span><span class="token string">"24"</span> Margin<span class="token operator">=</span><span class="token string">"5"</span> Value <span class="token operator">=</span><span class="token string">"{Binding Input2}"</span><span class="token operator">/</span><span class="token operator">&gt;</span>
            
        <span class="token operator">&lt;</span><span class="token operator">/</span>StackPanel<span class="token operator">&gt;</span>
        <span class="token operator">&lt;</span>StackPanel Grid<span class="token punctuation">.</span>Row<span class="token operator">=</span><span class="token string">"2"</span> Orientation<span class="token operator">=</span><span class="token string">"Horizontal"</span><span class="token operator">&gt;</span>
            <span class="token operator">&lt;</span><span class="token class-name">TextBlock</span> Text<span class="token operator">=</span><span class="token string">"结果为:"</span> VerticalAlignment<span class="token operator">=</span><span class="token string">"Center"</span><span class="token operator">/</span><span class="token operator">&gt;</span>
            <span class="token operator">&lt;</span><span class="token class-name">Slider</span> x<span class="token punctuation">:</span>Name<span class="token operator">=</span><span class="token string">"textBox3"</span> Width<span class="token operator">=</span><span class="token string">"242"</span> Background<span class="token operator">=</span><span class="token string">"LightGreen"</span> FontSize<span class="token operator">=</span><span class="token string">"24"</span> Margin<span class="token operator">=</span><span class="token string">"5"</span> Value<span class="token operator">=</span><span class="token string">"{Binding Result}"</span><span class="token operator">/</span><span class="token operator">&gt;</span>
        <span class="token operator">&lt;</span><span class="token operator">/</span>StackPanel<span class="token operator">&gt;</span>
        <span class="token operator">&lt;</span><span class="token class-name">Button</span> x<span class="token punctuation">:</span>Name<span class="token operator">=</span><span class="token string">"btnAdd"</span> Content<span class="token operator">=</span><span class="token string">"相加"</span> Grid<span class="token punctuation">.</span>Row<span class="token operator">=</span><span class="token string">"3"</span> Width<span class="token operator">=</span><span class="token string">"120"</span> Height<span class="token operator">=</span><span class="token string">"40"</span> Command<span class="token operator">=</span><span class="token string">"{Binding AddCommand}"</span><span class="token operator">/</span><span class="token operator">&gt;</span>
    <span class="token operator">&lt;</span><span class="token operator">/</span>Grid<span class="token operator">&gt;</span>
<span class="token operator">&lt;</span><span class="token operator">/</span>Grid<span class="token operator">&gt;</span>

</Window>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44

在这里插入图片描述

</article>

转自 https://blog.csdn.net/asd497907957/article/details/121988579?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-1-121988579-blog-126736527.pc_relevant_landingrelevant&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-1-121988579-blog-126736527.pc_relevant_landingrelevant&utm_relevant_index=2

标签:gt,MVVM,C#,System,模式,lt,using,public
From: https://www.cnblogs.com/castlewu/p/16902649.html

相关文章

  • JFileChooser设置窗体打开路径
    JFileChooser作为Java中Swing的文件选取器,是放置在对话框中的轻量组件。通过该组件能够打开文件选取对话框,并记录所选文件,因此在软件开发过程中使用率很高。但是在使用过程......
  • Cantor表(NOIP1999)
    题目链接:​​Cantor表​​这道题很水,但有的人没看懂题意,这不怪大家,怪题目没说清楚。给张图:看到这,你应该明白题目意思了。先看看有什么规律。我把这个数列写出来:......
  • Likecloud—吃、吃、吃(P1508)
    题目链接:​​Likecloud—吃、吃、吃​​​这题的状态非常的自然。就是ans[i][j]表示从(i,j)出发,能得到的最大能量值。那么对应每一个点,我们只要选出他能到达的点的最大......
  • C语言:一元二次方程求解
    题目已知一元二次方程......
  • letcode算法--21.螺旋矩阵 II
    给你一个正整数 n ,生成一个包含 1 到 n2 所有元素,且元素按顺时针顺序螺旋排列的 nxn 正方形矩阵 matrix 。示例1:输入:n=3输出:[[1,2,3],[8,9,4],[7,6,5]]......
  • iOS 升级到XCode13以后运行模拟器经常导致MacOS系统卡死
    升级到XCode13后运行模拟器会导致MacOS系统卡死,升级到XCode14后,该问题仍然存在,当然也有可能是公司办公电脑配置太低导致的[dog],卡死频率很高,会导致整个屏幕无法操作,无法看......
  • 【HMS Core】使用图形引擎服务点击一次会多次触发RenderView的方法addOnTouchEventLis
    ​问题描述使用图形引擎服务点击一次会多次触发RenderView的方法addOnTouchEventListener 解决方案addOnTouchEventListener会有MotionEvent.ACTION_DOWN、MotionEven......
  • python模块 - copy模块
    copy模块用于对象的拷贝操作。该模块只提供了两个主要的方法:copy.copy与copy.deepcopy,分别表示浅复制与深复制。b=a.copy():浅拷贝,a和b是一个独立的对象,但他......
  • 【快应用】onShow, onHide, onBackpress, onMenuPress事件监听不执行
    ​现象描述代码中设置的onShow,onHide,onBackpress,onMenuPress事件监听没有执行。 问题分析此类问题一般是由于将自定义组件作为根节点导致的,错误代码示例如下:<......
  • 用SpringMVC 实现断点续传 (HTTP)
    ​ 一、概述 所谓断点续传,其实只是指下载,也就是要从文件已经下载的地方开始继续下载。在以前版本的HTTP协议是不支持断点的,HTTP/1.1开始就支持了。一般断点下载时才用......