In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today Xiaobian to share with you what is the method of C# WPF data binding template operation of the relevant knowledge, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for your reference, I hope you can learn something after reading this article, let's take a look at it.
The specific example code is as follows: public class NotifyPropertyObject: INotifyPropertyChanged {public event PropertyChangedEventHandler PropertyChanged; public void RaisePropertyChanged (string propertyName) {if (PropertyChanged! = null) {PropertyChanged.Invoke (this, new PropertyChangedEventArgs (propertyName));}} private MainWindowVM vm = new MainWindowVM () / / key public MainWindow () {InitializeComponent (); this.DataContext = vm;// key}
Step 2: create its model class for each interface, such as MainWindowVM,AzimuthWindowVM.,. Classes of this type also need to inherit from the class NotifyPropertyObject
Note: (1) the background implementation code is mainly added to this class, one is to make the background code as simple as possible, and the other is to facilitate data binding.
(2) in most cases, properties and methods are written in this class.
Example:
Public class MainWindowVM: NotifyPropertyObject {private double _ dmsL0; / / Central meridian longitude public double dmsL0 {get {return _ dmsL0;} set {_ dmsL0 = value; RaisePropertyChanged ("dmsL0") } public class AzimuthWindowVM: NotifyPropertyObject {private string azName = "A001-> B004 coordinate azimuth"; public string AzName {get {return azName;} set {azName = value; RaisePropertyChanged ("AzName");}
Step 3: if there is an interface-related quantity in the class, let the class inherit the class NotifyPropertyObject and bind it in the Set code block in the attribute in the derived class.
Public class Ellipsoid: NotifyPropertyObject {private double _ a; / / long axis public double a {get = > _ a; set {_ a = value; if (_ a > 0 & & f > 0) {Init (a, f) } RaisePropertyChanged ("a");}
Step 4: bind in the interface design code
Example:
1, 2, 3, Title= "{Binding Title}" Note: the title can also be bound. The above is all the content of the article "what is the method of templated operation of C # WPF data binding?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.