资源简介

关于使用MVVM 自定义控件,依赖属性的双向数据绑定方法,自己在网上找了很久很久,各大搜索都找过,最后总结的方法,希望对大家有作用,少走点弯路

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;

namespace ClassLibrary1
{
    public class MainWindow: ViewModelbase 
    {
        private string maintext;
        public string TextProperty
        {
            get { return maintext; }
            set
            {
                maintext = value;
                this.RaisePropertyChanged(“TextProperty“);
            }
        }

        public MainWindow()
        {
            
            TextProperty = “123456789“;
        }

        public ICommand TextCommand => new RelayCommand(this.MyPropertyExecute);

        private void MyPropertyExecute()
        {
            var aaa = TextProperty;
            TextProperty = $“check ok:{DateTime.Now}“;
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     85504  2015-05-15 14:17  MVVM Usercontrol\.vs\WpfApplication1\v14\.suo

     文件       5120  2015-05-15 13:53  MVVM Usercontrol\ClassLibrary1\bin\Debug\ClassLibrary1.dll

     文件      13824  2015-05-15 13:53  MVVM Usercontrol\ClassLibrary1\bin\Debug\ClassLibrary1.pdb

     文件      29696  2015-05-14 18:25  MVVM Usercontrol\ClassLibrary1\bin\Debug\GalaSoft.MvvmLight.dll

     文件      22016  2015-05-14 18:25  MVVM Usercontrol\ClassLibrary1\bin\Debug\GalaSoft.MvvmLight.Extras.dll

     文件      40448  2015-05-14 18:25  MVVM Usercontrol\ClassLibrary1\bin\Debug\GalaSoft.MvvmLight.Extras.pdb

     文件      36405  2015-05-14 18:25  MVVM Usercontrol\ClassLibrary1\bin\Debug\GalaSoft.MvvmLight.Extras.xml

     文件      87552  2015-05-14 18:25  MVVM Usercontrol\ClassLibrary1\bin\Debug\GalaSoft.MvvmLight.pdb

     文件     105606  2015-05-14 18:25  MVVM Usercontrol\ClassLibrary1\bin\Debug\GalaSoft.MvvmLight.xml

     文件      18112  2015-05-14 18:25  MVVM Usercontrol\ClassLibrary1\bin\Debug\Microsoft.Practices.ServiceLocation.dll

     文件      24064  2015-05-14 18:25  MVVM Usercontrol\ClassLibrary1\bin\Debug\Microsoft.Practices.ServiceLocation.pdb

     文件      15978  2015-05-14 18:25  MVVM Usercontrol\ClassLibrary1\bin\Debug\Microsoft.Practices.ServiceLocation.xml

     文件      39936  2015-05-14 18:25  MVVM Usercontrol\ClassLibrary1\bin\Debug\System.Windows.Interactivity.dll

     文件      62128  2015-05-14 18:25  MVVM Usercontrol\ClassLibrary1\bin\Debug\System.Windows.Interactivity.xml

     文件       3830  2015-05-15 13:51  MVVM Usercontrol\ClassLibrary1\ClassLibrary1.csproj

     文件        899  2015-05-15 13:53  MVVM Usercontrol\ClassLibrary1\MainWindow.cs

     文件       1812  2015-05-14 19:29  MVVM Usercontrol\ClassLibrary1\obj\Debug\ClassLibrary1.csproj.FileListAbsolute.txt

     文件       5120  2015-05-15 13:53  MVVM Usercontrol\ClassLibrary1\obj\Debug\ClassLibrary1.dll

     文件      13824  2015-05-15 13:53  MVVM Usercontrol\ClassLibrary1\obj\Debug\ClassLibrary1.pdb

     文件       7320  2015-05-15 13:50  MVVM Usercontrol\ClassLibrary1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        353  2015-05-14 18:25  MVVM Usercontrol\ClassLibrary1\packages.config

     文件       1350  2015-05-14 18:23  MVVM Usercontrol\ClassLibrary1\Properties\AssemblyInfo.cs

     文件        492  2015-05-15 14:14  MVVM Usercontrol\ClassLibrary1\UserControl1.cs

     文件      21056  2015-05-14 18:25  MVVM Usercontrol\packages\CommonServiceLocator.1.3\CommonServiceLocator.1.3.0.nupkg

     文件      18112  2015-05-14 18:25  MVVM Usercontrol\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll

     文件      24064  2015-05-14 18:25  MVVM Usercontrol\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.pdb

     文件      15978  2015-05-14 18:25  MVVM Usercontrol\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.xml

     文件        566  2015-05-14 18:25  MVVM Usercontrol\packages\CommonServiceLocator.1.3\[Content_Types].xml

     文件        979  2015-05-14 18:25  MVVM Usercontrol\packages\MvvmLight.5.1.1.0\Content\ViewModel\MainViewModel.cs.pp

     文件       1834  2015-05-14 18:25  MVVM Usercontrol\packages\MvvmLight.5.1.1.0\Content\ViewModel\ViewModelLocator.cs.pp

............此处省略230个文件信息

评论

共有 条评论