{"id":225,"date":"2022-12-29T19:53:57","date_gmt":"2022-12-29T11:53:57","guid":{"rendered":"https:\/\/www.jinhaihan.top\/WordPress\/?p=225"},"modified":"2022-12-29T19:54:00","modified_gmt":"2022-12-29T11:54:00","slug":"wpf-databinding%e7%9a%84%e5%87%a0%e7%a7%8d%e6%96%b9%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/www.jinhaihan.top\/WordPress\/wpf-databinding%e7%9a%84%e5%87%a0%e7%a7%8d%e6%96%b9%e5%bc%8f\/","title":{"rendered":"<strong># WPF Databinding\u7684\u51e0\u79cd\u65b9\u5f0f<\/strong>"},"content":{"rendered":"\n<div class=\"wp-block-jetpack-markdown\"><h1>WPF Databinding\u7684\u51e0\u79cd\u65b9\u5f0f<\/h1>\n<p>\u6709\u65f6\u5019\u4f1a\u548cUWP\u3001\u5176\u4ed6\u8bed\u8a00\u7684\u7ed1\u5b9a\u5f04\u6df7\uff0c\u8fd9\u91cc\u505a\u4e00\u4e0b\u5907\u4efd\u8bb0\u5f55<\/p>\n<p>\u4e24\u79cd\u60c5\u51b5\uff0c\u4e00\u79cd\u4f7f\u7528viewmodel\uff0c\u4e00\u79cd\u76f4\u63a5\u7ed1\u5b9a\u3002<\/p>\n<h1>\u4e00\u3001\u76f4\u63a5\u7ed1\u5b9a<\/h1>\n<p>\u8981\u7ed1\u5b9a\u7684\u5bf9\u8c61\uff08\u6bd4\u5982page\u3001Window\uff09\u76f4\u63a5\u5b9e\u73b0<code>INotifyPropertyChanged<\/code>\u63a5\u53e3\uff0c\u5982\u4e0b\u4f8b\u5b50\uff1a<\/p>\n<pre><code class=\"language-C#\"> public partial class LoginPage : Page, INotifyPropertyChanged\n{\n        bool SettingsShow = false;\n\n\n        private string intvalue = &quot;aaa&quot;;\/\/\u79c1\u6709\n\n        public event PropertyChangedEventHandler? PropertyChanged;\n\n        public string IntValue\n        {\n            get { return intvalue; }\/\/\u83b7\u53d6\u503c\u65f6\u5c06\u79c1\u6709\u5b57\u6bb5\u4f20\u51fa\uff1b\n            set\n            {\n                intvalue = value;\/\/\u8d4b\u503c\u65f6\u5c06\u503c\u4f20\u7ed9\u79c1\u6709\u5b57\u6bb5\n                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(&quot;IntValue&quot;));\/\/\u4e00\u65e6\u6267\u884c\u4e86\u8d4b\u503c\u64cd\u4f5c\u8bf4\u660e\u5176\u503c\u88ab\u4fee\u6539\u4e86\uff0c\u5219\u7acb\u9a6c\u901a\u8fc7INotifyPropertyChanged\u63a5\u53e3\u544a\u8bc9UI(IntValue)\u88ab\u4fee\u6539\u4e86\n            }\n        }\n\n        public LoginPage()\n        {\n            InitializeComponent();\n            DataContext= this;\n        }\n}\n<\/code><\/pre>\n<p>\u5728\u5e03\u5c40\u6587\u4ef6\u4e2d\u6807\u6ce8\uff1a<\/p>\n<pre><code> d:DataContext=&quot;{d:DesignInstance Type=local:LoginPage}&quot;\n<\/code><\/pre>\n<p>\u5c31\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u7c7b\u4f3c<code> Text=&quot;{Binding IntValue}&quot;<\/code>\u8fd9\u6837\u7684\u65b9\u5f0f\u7ed1\u5b9a\u4e86<\/p>\n<h1>\u4e8c\u3001\u4f7f\u7528viewmodel<\/h1>\n<p>\u4f7f\u7528mvvm\u5e93\nNuget\u5b89\u88c5CommunityToolkit.Mvvm<\/p>\n<pre><code class=\"language-C#\">public class TicketSaleViewmodel : ObservableRecipient\n{\n\n    public class Customer\n    {\n        public string FirstName { get; set; }\n        public string LastName { get; set; }\n        public string Email { get; set; }\n        public bool IsMember { get; set; }\n    }\n\n    public string a = &quot;asd&quot;;\n\n    public string A\n    {\n        get { return a; }\n        set { a = value; OnPropertyChanged(nameof(A));}\n    }\n\n    private ObservableCollection&lt;YourBean&gt; _myBeans = new ObservableCollection&lt;YourBean&gt;(){};\n\n    public ObservableCollection&lt;YourBean&gt; MyBeans\n    {\n        get { return _myBeans;}\n        set { _myBeans = value; OnPropertyChanged(nameof(MyBeans));}\n    }\n}\n<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":226,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[21,7],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/12\/pexels-photo-417173.jpeg?fit=1880%2C1253&ssl=1","jetpack-related-posts":[{"id":205,"url":"https:\/\/www.jinhaihan.top\/WordPress\/wpf%e4%b8%ad%e7%9a%84%e5%a4%9a%e8%af%ad%e8%a8%80%e6%94%af%e6%8c%81_%e5%8a%a8%e6%80%81%e5%88%87%e6%8d%a2%e8%af%ad%e8%a8%80\/","url_meta":{"origin":225,"position":0},"title":"wpf\u4e2d\u7684\u591a\u8bed\u8a00\u652f\u6301_\u52a8\u6001\u5207\u6362\u8bed\u8a00","author":"Kim","date":"2022\u5e748\u670831\u65e5","format":false,"excerpt":"\u4e3b\u6d41\u65b9\u6cd5\u53c2\u8003\u535a\u5ba2\uff1a(\u867d\u7136\u8001\u4e86\u70b9\u4f46\u662f\u6709\u7528) WPF\u5e94\u7528\u7a0b\u5e8f\u652f\u6301\u591a\u56fd\u8bed\u8a00\u89e3\u51b3\u65b9\u6848 \u4f46\u662f\u9ed8\u8ba4\u7684\u65b9\u6848\u91cc\u8bd5\u7528\u9759\u2026","rel":"","context":"\u5728\u201cWPF\u201d\u4e2d","block_context":{"text":"WPF","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/wpf\/"},"img":{"alt_text":"pieces of paper with words","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/08\/pexels-photo-6045344.jpeg?fit=1200%2C795&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/08\/pexels-photo-6045344.jpeg?fit=1200%2C795&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/08\/pexels-photo-6045344.jpeg?fit=1200%2C795&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/08\/pexels-photo-6045344.jpeg?fit=1200%2C795&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":228,"url":"https:\/\/www.jinhaihan.top\/WordPress\/databinding%e7%bb%91%e5%ae%9a%e4%b8%8d%e5%90%8c%e4%b8%8a%e4%b8%8b%e6%96%87%e7%9a%84%e5%b1%9e%e6%80%a7\/","url_meta":{"origin":225,"position":1},"title":"Databinding\u7ed1\u5b9a\u4e0d\u540c\u4e0a\u4e0b\u6587\u7684\u5c5e\u6027","author":"Kim","date":"2022\u5e7412\u670830\u65e5","format":false,"excerpt":"\u7ed1\u5b9a\u67d0\u7236\u7ea7\u7684\u5c5e\u6027 \u5047\u8bbe\u573a\u666f\uff1a \u5b58\u5728\u4e00\u4e2a\u5df2\u7ecf\u8bbe\u7f6e\u4e86Item source\u7684ListView\uff0cListV\u2026","rel":"","context":"\u5728\u201cWPF\u201d\u4e2d","block_context":{"text":"WPF","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/wpf\/"},"img":{"alt_text":"The Rhine\u2013Meuse\u2013Scheldt river delta in the Netherlands","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/12\/49830289321_83c90a1dd4_b.jpg?fit=1024%2C683&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/12\/49830289321_83c90a1dd4_b.jpg?fit=1024%2C683&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/12\/49830289321_83c90a1dd4_b.jpg?fit=1024%2C683&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":192,"url":"https:\/\/www.jinhaihan.top\/WordPress\/ue5-ik-retarget-%e9%87%8d%e5%ae%9a%e5%90%91%e5%8a%a8%e7%94%bb%e6%b2%a1%e6%9c%89rootmotion%e7%9a%84%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95\/","url_meta":{"origin":225,"position":2},"title":"UE5 IK Retarget \u91cd\u5b9a\u5411\u52a8\u753b\u6ca1\u6709RootMotion\u7684\u89e3\u51b3\u65b9\u6cd5","author":"Kim","date":"2022\u5e747\u67088\u65e5","format":false,"excerpt":"\u5c0f\u7ec6\u8282\uff0c\u5728IK Retarget\u7684\u8282\u70b9Chain Mapping\u91cc\u9762\u53ef\u4ee5\u8bbe\u7f6e\u6bcf\u4e2a\u8282\u70b9\u7684\u91cd\u5b9a\u5411\u65b9\u5f0f\uff0c\u70b9\u2026","rel":"","context":"\u5728\u201c\u535a\u5ba2\u201d\u4e2d","block_context":{"text":"\u535a\u5ba2","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/"},"img":{"alt_text":"landscape photograph of body of water","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/pexels-photo-1001682.jpeg?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/pexels-photo-1001682.jpeg?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/pexels-photo-1001682.jpeg?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/pexels-photo-1001682.jpeg?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":197,"url":"https:\/\/www.jinhaihan.top\/WordPress\/197\/","url_meta":{"origin":225,"position":3},"title":"gradle\u7684java\u9879\u76eeLombok\u62a5\u9519\u7684\u89e3\u51b3\u65b9\u5f0f","author":"Kim","date":"2022\u5e747\u670830\u65e5","format":false,"excerpt":"\u4e00. \u68c0\u67e5\u9879\u76ee\u914d\u7f6e \u5982\u5176\u4ed6\u535a\u5ba2\u6240\u8bf4\uff0c\u4f18\u5148\u68c0\u67e5\u9879\u76ee\u914d\u7f6e 1. \u68c0\u67e5\u9879\u76ee\u4f9d\u8d56\u662f\u5426\u6b63\u5e38\uff0c\u5305\u62ec\u6ce8\u89e3\u5904\u7406\u5668 \u5728\u2026","rel":"","context":"\u5728\u201cJava\u201d\u4e2d","block_context":{"text":"Java","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/java\/"},"img":{"alt_text":"grey white clouds","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/clouds-cloudporn-weather-lookup-158163.jpeg?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/clouds-cloudporn-weather-lookup-158163.jpeg?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/clouds-cloudporn-weather-lookup-158163.jpeg?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/clouds-cloudporn-weather-lookup-158163.jpeg?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":235,"url":"https:\/\/www.jinhaihan.top\/WordPress\/%e5%9c%a8gin%e6%a1%86%e6%9e%b6%e4%b8%ad%e8%8e%b7%e5%8f%96%e5%a4%96%e9%83%a8%e8%af%b7%e6%b1%82%e4%b8%adget%e5%92%8cpost%e7%9a%84%e5%8f%82%e6%95%b0\/","url_meta":{"origin":225,"position":4},"title":"\u5728Gin\u6846\u67b6\u4e2d\u83b7\u53d6\u5916\u90e8\u8bf7\u6c42\u4e2dGet\u548cPost\u7684\u53c2\u6570","author":"Kim","date":"2023\u5e741\u670831\u65e5","format":false,"excerpt":"\u9996\u5148\u5047\u8bbe\u5df2\u7ecf\u642d\u5efa\u597d\u6574\u4e2a\u670d\u52a1\uff0c\u5e76\u521b\u5efa\u4e86\u51e0\u4e2aAPI\u7528\u4e8e\u6d4b\u8bd5\u3002 \u5728Get\u8bf7\u6c42\u4e2d\uff0c\u5047\u8bbe\u7531\u4ee5\u4e0b\u51fd\u6570\u5904\u7406\uff0c\u5219\u83b7\u53d6\u2026","rel":"","context":"\u5728\u201cGolang\u201d\u4e2d","block_context":{"text":"Golang","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/golang\/"},"img":{"alt_text":"Dynamic Earth - Ocean Currents","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2023\/01\/7402441936_5c99447ca0_b.jpg?fit=1024%2C576&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2023\/01\/7402441936_5c99447ca0_b.jpg?fit=1024%2C576&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2023\/01\/7402441936_5c99447ca0_b.jpg?fit=1024%2C576&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":37,"url":"https:\/\/www.jinhaihan.top\/WordPress\/databinding%e8%87%aa%e5%ae%9a%e4%b9%89%e6%96%b9%e6%b3%95%e3%80%81%e5%8f%82%e6%95%b0%e7%bb%91%e5%ae%9a%ef%bc%88bindingadapter%ef%bc%89\/","url_meta":{"origin":225,"position":5},"title":"DataBinding\u81ea\u5b9a\u4e49\u65b9\u6cd5\u3001\u53c2\u6570\u7ed1\u5b9a\uff08BindingAdapter\uff09","author":"Kim","date":"2020\u5e7411\u670830\u65e5","format":false,"excerpt":"\u53c2\u8003\u6587\u6863\uff1a https:\/\/blog.csdn.net\/guiying712\/article\/det\u2026","rel":"","context":"\u5728\u201cAndroid\u201d\u4e2d","block_context":{"text":"Android","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/android\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/9d44955fb48b1ee67f28e63a99bbd4a2.jpg?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/9d44955fb48b1ee67f28e63a99bbd4a2.jpg?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/9d44955fb48b1ee67f28e63a99bbd4a2.jpg?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/9d44955fb48b1ee67f28e63a99bbd4a2.jpg?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/posts\/225"}],"collection":[{"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/comments?post=225"}],"version-history":[{"count":1,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/posts\/225\/revisions"}],"predecessor-version":[{"id":227,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/posts\/225\/revisions\/227"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/media\/226"}],"wp:attachment":[{"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/media?parent=225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/categories?post=225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/tags?post=225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}