Skip to content

Instantly share code, notes, and snippets.

View runceel's full-sized avatar

Kazuki Ota runceel

View GitHub Profile
class ViewModel
{
public ReactiveProperty<string> Input { get; }
public ReactiveProperty<string> Output { get; }
public ViewModel()
{
Input = new ReactiveProperty("");
Output = Input
.Delay(TimeSpan.FromSecond(1)) // Using a Rx method.
<TextBlock Text="{Binding Message.Value}" />
var viewModel = new SomeViewModel();
viewModel.Message.Value = "Hello world"; // set a value
Console.WriteLine(viewModel.Message.Value); // get a value
public interface IReactiveProperty<T> : IObservable<T>, INotifyPropertyChanged
{
T Value { get; set; }
}
public class ReactiveProperty<T> : IReactiveProperty<T>
{
public event PropertyChangedEventHandler PropertyChanged;
private T _value;
public class SomeViewModel // You don't need implementation of INotifyPropertyChanged
{
public ReactiveProperty<string> Message { get; } = new ReactiveProperty<string>();
}
public class SomeViewModel : BindableBase
{
private string _message;
public string Message
{
get { return _message; }
set { SetProperty(ref _message, value); }
}
}
public class BindableBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual bool SetProperty<T>(ref T field, T value, [CallerMemberName]string propertyName)
{
if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
storage = value;
RaisePropertyChanged(propertyName);
return true;
public class SomeViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private string _message;
public string Message
{
get { return _message; }
set
{
using Moq;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp10
{
class Program
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Unity;
using Unity.Lifetime;
namespace LINQLab
{
class Program