Nov 7 |
Posted by Andrew on 07 November 2018 01:33 PM
|
A while ago we announced we had open sourced the small but useful WPF Transitionz library for Metro Style Animation effects in WPF applications. To our surprise this now has over 5,000 downloads on NuGet.org and even received a couple of questions & bug reports via the Github repository! We’re using the four libraries in SciChart.Wpf.Ui in our SciChart WPF Examples Suite, and also starting to use them in consultancy projects, so we’ve updated them for 2018 to be compatible with .NET Standard 2.0 and .NET 4.6.1, plus fixed a number of bugs & added other improvements. What’s in SciChart.Wpf.UI ?So what’s in this mysterious collection of open source libraries? A quick run-down below. SciChart.UI.BootstrapSupporting .NET Standard 2.0 / .NET Framework 4.6.1 and above, this library includes bootstrapper classes for WPF Applications using Unity and allowing automatic dependency discovery across a range of assemblies. See the Bootstrap Library Overview page at SciChart.Wpf.UI. To use it,
SciChart.UI.ReactiveThe SciChart.UI.Reactive library supports .NET Standard 2.0 / .NET Framework 4.6.1 and above provides observable viewmodels which combine INotifyPropertyChanged event notifications for WPF, and Reactive IObservable streams for observing individual, or combinations of properties. See Reactive Library Overview and Reactive Library WhenPropertyChanged wiki pages. The main benefit of this library is that it brings the incredible power of Reactive Extensions to MVVM in WPF applications. You declare a class like this: public class WhenPropertyChangedTests : ObservableObjectBase { public string SearchText { get => GetDynamicValue(); set => SetDynamicValue(value); } public SearchOptions SearchOptions { get => GetDynamicValue(); set => SetDynamicValue(value); } } and now any of these properties raise both PropertyChanged events as well as a reactive stream (IObservable<T>). You also don’t have to create a backing field making all your properties, these are stored in the base class (ObservableObjectBase) in a dictionary. Properties may now be observed using Reactive Extensions as follows: void Foo() { // Create the ViewModel WhenPropertyChangedTests vm = new WhenPropertyChangedTests(); // Observe properties var observable1 = vm.WhenPropertyChanged(x => x.SearchText); var observable2 = vm.WhenPropertyChanged(x => x.SearchOptions); // Subscribe var disposable = observable1.Subscribe(t => Console.WriteLine($"Search Text = '{t}'")); // Set properties vm.SearchText = "Hello"; // -> Should output 'Search Text = 'Hello'' to console vm.SearchText = "World"; // -> Should output 'Search Text = 'World'' to console disposable.Dispose(); vm.SearchText = "Not observed"; // nothing happens } and multiple properties may be observed using Observable.CombineLatest void Foo() { // Create the ViewModel WhenPropertyChangedTests vm = new WhenPropertyChangedTests(); // Observe properties var observable1 = vm.WhenPropertyChanged(x => x.SearchText); var observable2 = vm.WhenPropertyChanged(x => x.SearchOptions); // Subscribe var disposable = Observable.CombineLatest(observable1, observable2, Tuple.Create) .Subscribe(t => Console.WriteLine($"Search Text = '{t.Item1}', Options = '{t.Item2}'")); // Set properties // // -> Should output 'Search Text = 'Hello', Options = 'AnOption'' to console vm.SearchText = "Hello"; // -> Should output 'Search Text = 'Hello', Options = 'AnotherOption'' to console vm.SearchOptions = SearchOptions.AnotherOption; // -> Should output 'Search Text = 'World', Options = 'AnotherOption'' to console vm.SearchText = "World"; disposable.Dispose(); vm.SearchText = "Not observed"; // nothing happens } If you haven’t checked out Reactive Extensions yet and seen what it can do for your WPF applications, or even server-side applications, then do so. It’s brilliant! Learning resources: SciChart.WPF.UI.TransitionzThe Transitionz library seems pretty popular with WPF developers as it provides a very simple way to animate elements on the UI with just Xaml attached properties. Transitionz supports WPF / .NET 4.6.1 and above and allows the following effects in your application:
All Transitionz animations may be triggered on:
Head over to the Transitionz Library wiki page for more information. We also have a small test-app bundled with SciChart.WPF.UI which demonstrates this functionality.
SciChart.WPF.UIThe SciChart.Wpf.UI assembly supports WPF / .NET 4.6.1 and above, and brings a number of useful controls to WPF applications, and metro styles based on MahApps.Metro. Controls include:
Where to Get itThe SciChart.WPF.UI libraries are free & open source and may be used in commercial projects under the Apache 2.0 license. Packages are published to NuGet.org and source code is available on Github.
About UsSciChart is a self-funded and profitable startup based in London, U.K., which specialises in High Performance, Realtime Chart controls as well as expert consultancy in complex .NET UI / Server applications. Connect with me on LinkedIn to find out more about our background and capabilities. If you have a bespoke requirement and want to hire our world-class consultants, then get in touch!
The post Open Source SciChart.UI.Reactive and SciChart.WPF.UI.Transitionz v2.1 Released appeared first on Fast, Native Chart Controls for WPF, iOS, Android and Xamarin. | |