{"id":82,"date":"2018-10-04T04:46:26","date_gmt":"2018-10-04T04:46:26","guid":{"rendered":"https:\/\/engy.us\/blog\/?p=82"},"modified":"2018-10-04T04:46:26","modified_gmt":"2018-10-04T04:46:26","slug":"item-change-tracking-in-dynamicdata","status":"publish","type":"post","link":"https:\/\/engy.us\/blog\/2018\/10\/04\/item-change-tracking-in-dynamicdata\/","title":{"rendered":"Item change tracking in DynamicData"},"content":{"rendered":"<p>Since ReactiveUI&#8217;s ReactiveList&lt;T&gt; has recently been deprecated, I&#8217;ve been moving to <a href=\"https:\/\/github.com\/RolandPheasant\/DynamicData\">DynamicData<\/a>.<\/p>\n<p>One feature I used from ReactiveList was item change tracking. It might look something like this:<\/p>\n<pre>var myList = new ReactiveList&lt;MyClass&gt;();\r\nmyList.ChangeTrackingEnabled = true;\r\nmyList.ItemChanged\r\n\t.Where(x =&gt; x.PropertyName == nameof(MyClass.SomeProperty))\r\n\t.Select(x =&gt; x.Sender)\r\n\t.Subscribe(myObject =&gt;\r\n\t{\r\n\t\t\/\/ Do some stuff\r\n\t});\r\n<\/pre>\n<p>In DynamicData it goes like this:<\/p>\n<pre>var myList = new SourceList&lt;MyClass&gt;();\r\nmyList\r\n\t.Connect()\r\n\t.WhenPropertyChanged(myObject =&gt; myObject.SomeProperty)\r\n\t.Subscribe(propValue =&gt;\r\n\t{\r\n\t\tMyClass myObject = propValue.Sender;\r\n\t\tstring newValue = propValue.Value;\r\n\t\t\/\/ Do some stuff\r\n\t});\r\n<\/pre>\n<p>There is also WhenValueChanged, which just gives you the new property value as a straight IObservable:<\/p>\n<pre>myList\r\n\t.Connect()\r\n\t.WhenValueChanged(myObject =&gt; myObject.SomeProperty)\r\n\t.Subscribe(newValue =&gt;\r\n\t{\r\n\t\t\/\/ Do some stuff\r\n\t});\r\n<\/pre>\n<p>The most powerful is WhenAnyPropertyChanged, which can tell you when any of the properties changed:<\/p>\n<pre>var myList = new SourceList&lt;MyClass&gt;();\r\nmyList\r\n\t.Connect()\r\n\t.WhenAnyPropertyChanged()\r\n\t.Subscribe(myObject =&gt;\r\n\t{\r\n\t\t\/\/ Do stuff with myObject\r\n\t});\r\n<\/pre>\n<p>Or when any set of specified properties has changed:<\/p>\n<pre>var myList = new SourceList&lt;MyClass&gt;();\r\nmyList\r\n\t.Connect()\r\n\t.WhenAnyPropertyChanged(nameof(MyClass.FirstProperty), nameof(MyClass.SecondProperty))\r\n\t.Subscribe(myObject =&gt;\r\n\t{\r\n\t\t\/\/ Do stuff with myObject\r\n\t});\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Since ReactiveUI&#8217;s ReactiveList&lt;T&gt; has recently been deprecated, I&#8217;ve been moving to DynamicData. One feature I used from ReactiveList was item change tracking. It might look something like this: var myList = new ReactiveList&lt;MyClass&gt;(); myList.ChangeTrackingEnabled = true; myList.ItemChanged .Where(x =&gt; x.PropertyName == nameof(MyClass.SomeProperty)) .Select(x =&gt; x.Sender) .Subscribe(myObject =&gt; { \/\/ Do some stuff }); In DynamicData &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/engy.us\/blog\/2018\/10\/04\/item-change-tracking-in-dynamicdata\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Item change tracking in DynamicData&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pahBcK-1k","jetpack-related-posts":[{"id":79,"url":"https:\/\/engy.us\/blog\/2018\/10\/03\/wpf-databinding-using-dynamicdata\/","url_meta":{"origin":82,"position":0},"title":"WPF Databinding using DynamicData","date":"October 3, 2018","format":false,"excerpt":"My project is MVVM and I had been using ReactiveList<T> as my go-to observable collection for viewmodel properties. But ReactiveUI deprecated ReactiveList in 8.6.1. So I needed to get on to the new recommended library: DynamicData. But there is no direct drop-in replacement you can do like ObservableCollection<T> <-> ReactiveList<T>.\u2026","rel":"","context":"With 2 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":146,"url":"https:\/\/engy.us\/blog\/2021\/02\/28\/installing-net-5-runtime-automatically-with-inno-setup\/","url_meta":{"origin":82,"position":1},"title":"Installing .NET 5 Runtime Automatically with Inno Setup","date":"February 28, 2021","format":false,"excerpt":"In this guide I will walk through how to get the .NET 5 runtime to download and install on-the-fly in an Inno Setup installer. It works in 3 steps: Detect if the desired .NET runtime is installedDownload the .NET Runtime bootstrap installer with Inno Download PluginRun the bootstrap installer in\u2026","rel":"","context":"With 2 comments","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/engy.us\/blog\/wp-content\/uploads\/2021\/02\/image.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":51,"url":"https:\/\/engy.us\/blog\/2015\/07\/17\/installing-net-framework-4-5-automatically-with-inno-setup\/","url_meta":{"origin":82,"position":2},"title":"Installing .NET Framework 4.7 automatically with Inno Setup","date":"July 17, 2015","format":false,"excerpt":"In this guide I will walk through how to get the .NET framework to download and install on-the-fly in an Inno Setup installer. It works in 3 steps: Detect if the desired .NET framework is installed Download the .NET Framework bootstrap installer with Inno Download Plugin Run the bootstrap installer\u2026","rel":"","context":"In \".net framework 4.5 inno setup\"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/engy.us\/blog\/wp-content\/uploads\/2015\/07\/7028.InstallingFramework2-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":120,"url":"https:\/\/engy.us\/blog\/2020\/01\/01\/implementing-a-custom-window-title-bar-in-wpf\/","url_meta":{"origin":82,"position":3},"title":"Implementing a Custom Window Title Bar in WPF","date":"January 1, 2020","format":false,"excerpt":"There are several good reasons for wanting custom window chrome in WPF, such as fitting in additional UI or implementing a Dark theme. However the actual implementation is kind of tricky, since it is now your job to provide a bunch of features that you used to get for free.\u2026","rel":"","context":"With 12 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":165,"url":"https:\/\/engy.us\/blog\/2021\/10\/03\/efficient-svg-icons-in-web-components-with-webpack-and-svgo\/","url_meta":{"origin":82,"position":4},"title":"Efficient SVG icons in Web Components with Webpack and SVGO","date":"October 3, 2021","format":false,"excerpt":"So many ways to load them There are a lot of different ways to show an SVG on a webpage: <img>, <embed>, <object>, <iframe>, <canvas> and <svg> among them. I think for any halfway modern browser there are really only two serious contenders here. Referencing an SVG file: <img src=\"image.svg\"\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":88,"url":"https:\/\/engy.us\/blog\/2018\/10\/20\/dark-theme-in-wpf\/","url_meta":{"origin":82,"position":5},"title":"Dark Theme in WPF","date":"October 20, 2018","format":false,"excerpt":"In a recent Windows 10 update a toggle switch was added to allow the user to specify that they wanted \"Dark\" themes in apps: I decided to add support for this to VidCoder. But no updates to WPF were made to make this easy. WPF does having theming support where\u2026","rel":"","context":"With 5 comments","img":{"alt_text":"","src":"https:\/\/i2.wp.com\/engy.us\/blog\/wp-content\/uploads\/2018\/10\/VidCoderDarkExample.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/engy.us\/blog\/wp-json\/wp\/v2\/posts\/82"}],"collection":[{"href":"https:\/\/engy.us\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/engy.us\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/engy.us\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/engy.us\/blog\/wp-json\/wp\/v2\/comments?post=82"}],"version-history":[{"count":1,"href":"https:\/\/engy.us\/blog\/wp-json\/wp\/v2\/posts\/82\/revisions"}],"predecessor-version":[{"id":84,"href":"https:\/\/engy.us\/blog\/wp-json\/wp\/v2\/posts\/82\/revisions\/84"}],"wp:attachment":[{"href":"https:\/\/engy.us\/blog\/wp-json\/wp\/v2\/media?parent=82"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/engy.us\/blog\/wp-json\/wp\/v2\/categories?post=82"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/engy.us\/blog\/wp-json\/wp\/v2\/tags?post=82"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}