本文整理汇总了C#中ReactiveCommand.BindTo方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveCommand.BindTo方法的具体用法?C# ReactiveCommand.BindTo怎么用?C# ReactiveCommand.BindTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReactiveCommand
的用法示例。
在下文中一共展示了ReactiveCommand.BindTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GamesViewModel
public GamesViewModel(ISelectionCollectionHelper<IGameItemViewModel> items) {
if (items == null)
throw new ArgumentNullException(nameof(items));
Games = items;
_openBrowse =
ReactiveCommand.CreateAsyncTask(
async x =>
await
RequestAsync(new OpenWebLink(ViewType.Browse, Games.SelectedItem.Slug))
.ConfigureAwait(false))
.DefaultSetup("OpenWeb");
_changeGame = ReactiveCommand.CreateAsyncTask(
async x => await RequestAsync(new ChangeGame(((IGameItemViewModel) x).Id)).ConfigureAwait(false))
.DefaultSetup("ChangeGame");
_changeGame.BindTo(this, x => x.Game);
_configureGameDirectory =
ReactiveCommand.CreateAsyncTask(
async x =>
await
OpenScreenCached(new GetSettings {SelectGameTab = true})
.ConfigureAwait(false))
.DefaultSetup("Configure Game Directory");
this.WhenActivated(d => {
d(this.WhenAnyValue(x => x.Games.SelectedItem)
.Where(x => x != null)
.ObserveOnMainThread()
.InvokeCommand(_changeGame));
d(Listen<ApiGameSelected>()
.Select(x => Games.Items.Find(x.Game.Id))
.ObserveOnMainThread()
.BindTo(this, x => x.Games.SelectedItem));
d(Listen<GameSettingsUpdated>()
.Select(x => new {x, Game = Games.Items.Find(x.Game.Id)})
.ObserveOnMainThread()
.Subscribe(x => {
if (x.x.Game.InstalledState.IsInstalled && x.Game == null) {
var item = x.x.Game.MapTo<GameItemViewModel>();
Games.Items.Add(item);
if (Games.Items.Count == 1)
Games.SelectedItem = item;
} else if (!x.x.Game.InstalledState.IsInstalled && x.Game != null)
Games.Items.Remove(x.Game);
}));
});
}