Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
Например, указывая в привязке Model.Property1.Property2.Property3 мы автоматически получаем отслеживание изменения в Property1, 2 и 3 одновременно.
this[() => Text].PropertyChanging += (o, args) => { ... };
this[() => Text].PropertyChanged += (o, args) => { ... };
[DataContract]
public class GuyViewModel : ContextObject, IExposable
{
[DataMember]
public int Kisses
{
get { return Get(() => Kisses); }
set { Set(() => Kisses, value); }
}
public void Expose()
{
var girlViewModel = Store.Get<GirlViewModel>();
this[() => Kisses].PropertyChanged += (sender, args) =>
{
Context.Get("KissGirl").RaiseCanExecuteChanged();
Context.Get("KissGuy").RaiseCanExecuteChanged();
};
this[Context.Get("KissGirl")].CanExecute += (sender, args) =>
args.CanExecute = Kisses > girlViewModel.Kisses - 2;
this[Context.Get("KissGirl")].Executed += (sender, args) =>
girlViewModel.Kisses++;
}
}
this[() => Mouse].ErrorsChanged += (sender, args) => HasErrors = !(5 < Mouse.Length && Mouse.Length < 20);
this[() => Mouse].ValidationRules += s => 5 < Mouse.Length && Mouse.Length < 20 ? null : "Invalid Length";
verifiableObject.ForProperty(vo => vo.TotalSize).AddValidationRule(s => s > 20);
verifiableObject.ForObject().AddAsyncValidationRule(ct => ValidateLengthAsync(ct)).AlsoValidate(vo => vo.TotalSize);
this[MediaCommands.Play].CanExecute += (sender, args) => args.CanExecute = IsStopped;
this[Context.Get("HelloCommand")].Executed += (sender, args) => MessageBox.Show("Hello!");
MyCommand = new RelayCommandBuilder(p => DoSomeWork(p)).AddCanExecute(p => p.ReadyToWork).InvalidateOnNotify(_myDependency, md => md.SomeProperty).AddBlocker(_myServiceExecutor).CreateCommand();

this[() => Kisses].PropertyChanged += (sender, args) =>
{
Context.Get("KissGirl").RaiseCanExecuteChanged();
Context.Get("KissGuy").RaiseCanExecuteChanged();
};
this[() => Kisses].PropertyChanged += (sender, args) =>
{
if (Kesses < 10) return;
Context.Get("KissGirl").RaiseCanExecuteChanged();
Context.Get("KissGuy").RaiseCanExecuteChanged();
};
this[Context.Refresh].Executed += async (sender, args) =>
{
try
{
IsBusy = true;
User = await server.GetUserData(Login, Password);
}
finally
{
IsBusy = false;
}
};
AfterNotify(() => Kisses).Execute(() =>
{
if (Kesses < 10) return;
_myFirstCommand.RaiseCanExecuteChanged();
_anotherOneCommand.RaiseCanExecuteChanged();
});
GetUserCommand = new RelayCommandBuilder<int>(async id => User await userServiceExecutor.Execute(us => us.GetUser(id))).CreateCommand();
AfterNotify(() => Scene.Dimension).Execute(async () => await OnCombine(Scene.Dimension));
this[() => Text].PropertyChanged += async (sender, args) =>
{
IsSaved = await server.SaveText(Text);
};
Базовая реализация INotifyPropertyChanged