### UWP View Model Integration Source: https://github.com/runceel/reactiveproperty/blob/main/docs/docs/features/Collections.md Example of binding a ViewModel to a UWP MainPage. ```csharp public sealed partial class MainPage : Page { public ViewModel ViewModel { get; } = new ViewModel(); public MainPage() { this.InitializeComponent(); } } ``` -------------------------------- ### AsyncMessageBroker PublishAsync Example Source: https://github.com/runceel/reactiveproperty/blob/main/docs/docs/features/Notifiers.md Illustrates asynchronous pub-sub messaging with AsyncMessageBroker. It shows how to subscribe to async messages and use PublishAsync to await subscriber completion. ```csharp AsyncMessageBroker.Default.Subscribe(async x => { Console.WriteLine("A:" + x); await Task.Delay(TimeSpan.FromSeconds(1)); }); var d = AsyncMessageBroker.Default.Subscribe(async x => { Console.WriteLine("B:" + x); await Task.Delay(TimeSpan.FromSeconds(2)); }); // await all subscriber complete await AsyncMessageBroker.Default.PublishAsync(new MyClass { MyProperty = 100 }); await AsyncMessageBroker.Default.PublishAsync(new MyClass { MyProperty = 200 }); await AsyncMessageBroker.Default.PublishAsync(new MyClass { MyProperty = 300 }); d.Dispose(); // unsubscribe await AsyncMessageBroker.Default.PublishAsync(new MyClass { MyProperty = 400 }); ``` -------------------------------- ### MessageBroker Pub-Sub Example Source: https://github.com/runceel/reactiveproperty/blob/main/docs/docs/features/Notifiers.md Demonstrates basic pub-sub messaging using MessageBroker. Includes subscribing to messages, converting to an observable, publishing messages, and unsubscribing. ```csharp using Reactive.Bindings.Notifiers; using System; using System.Reactive.Linq; using System.Threading.Tasks; public class MyClass { public int MyProperty { get; set; } public override string ToString() { return "MP:" + MyProperty; } } class Program { static void RunMessageBroker() { // global scope pub-sub messaging MessageBroker.Default.Subscribe(x => { Console.WriteLine("A:" + x); }); var d = MessageBroker.Default.Subscribe(x => { Console.WriteLine("B:" + x); }); // support convert to IObservable MessageBroker.Default.ToObservable().Subscribe(x => { Console.WriteLine("C:" + x); }); MessageBroker.Default.Publish(new MyClass { MyProperty = 100 }); MessageBroker.Default.Publish(new MyClass { MyProperty = 200 }); MessageBroker.Default.Publish(new MyClass { MyProperty = 300 }); d.Dispose(); // unsubscribe MessageBroker.Default.Publish(new MyClass { MyProperty = 400 }); } static async Task RunAsyncMessageBroker() { // asynchronous message pub-sub AsyncMessageBroker.Default.Subscribe(async x => { Console.WriteLine("A:" + x); await Task.Delay(TimeSpan.FromSeconds(1)); }); var d = AsyncMessageBroker.Default.Subscribe(async x => { Console.WriteLine("B:" + x); await Task.Delay(TimeSpan.FromSeconds(2)); }); // await all subscriber complete await AsyncMessageBroker.Default.PublishAsync(new MyClass { MyProperty = 100 }); await AsyncMessageBroker.Default.PublishAsync(new MyClass { MyProperty = 200 }); await AsyncMessageBroker.Default.PublishAsync(new MyClass { MyProperty = 300 }); d.Dispose(); // unsubscribe await AsyncMessageBroker.Default.PublishAsync(new MyClass { MyProperty = 400 }); } static void Main(string[] args) { Console.WriteLine("MessageBroker"); RunMessageBroker(); Console.WriteLine("AsyncMessageBroker"); RunAsyncMessageBroker().Wait(); } } ``` -------------------------------- ### UWP Page Setup for Validation Errors Source: https://github.com/runceel/reactiveproperty/blob/main/docs/docs/features/ReactiveProperty.md This C# code sets up a UWP page with a ViewModel that handles validation errors. It initializes the ViewModel and the page components. ```csharp public sealed partial class MainPage : Page { private ViewModel ViewModel { get; } = new ViewModel(); public MainPage() { this.InitializeComponent(); } } ``` -------------------------------- ### Bind AsyncReactiveCommand in XAML Source: https://github.com/runceel/reactiveproperty/blob/main/docs/docs/features/Commanding.md Example of binding the AsyncReactiveCommand and a ReactiveProperty to UI elements in a XAML page. ```xml