Few more binding fixes

This commit is contained in:
Timothy Baldridge 2021-11-03 23:13:25 -06:00
parent 0334a4f217
commit fd304d5b52
3 changed files with 29 additions and 19 deletions

View File

@ -30,7 +30,7 @@ public partial class FileSelectionBox : ReactiveUserControl<FileSelectionBoxView
this.WhenActivated(disposables =>
{
this.Bind(ViewModel, vm => vm.Path, view => view.SelectedPath)
this.OneWayBind(ViewModel, vm => vm.Path, view => view.SelectedPath)
.DisposeWith(disposables);
this.WhenAnyValue(view => view.SelectFolder)
.BindTo(ViewModel, vm => vm.SelectFolder)
@ -67,4 +67,9 @@ public partial class FileSelectionBox : ReactiveUserControl<FileSelectionBoxView
get => GetValue(SelectFolderProperty);
set => SetValue(SelectFolderProperty, value);
}
public void Load(AbsolutePath path)
{
ViewModel.Path = path;
}
}

View File

@ -29,7 +29,6 @@ public class InstallConfigurationViewModel : ViewModelBase, IActivatableViewMode
private readonly InstallationStateManager _stateManager;
private readonly SettingsManager _settingsManager;
public InstallConfigurationViewModel(DTOSerializer dtos, InstallationStateManager stateManager, SettingsManager settingsManager)
{
_stateManager = stateManager;
@ -89,7 +88,11 @@ public class InstallConfigurationViewModel : ViewModelBase, IActivatableViewMode
{
var path = await _settingsManager.Load<AbsolutePath>("last-install-path");
if (path != default && path.FileExists())
ModListPath = path;
{
Dispatcher.UIThread.Post(() => {
ModListPath = path;
});
}
}
[Reactive] public AbsolutePath ModListPath { get; set; }

View File

@ -18,30 +18,32 @@ public partial class InstallConfigurationView : ReactiveUserControl<InstallConfi
this.WhenActivated(disposables =>
{
this.Bind(ViewModel, x => x.ModListPath,
view => view.ModListFile.SelectedPath)
ViewModel.WhenAnyValue(vm => vm.ModListPath)
.Subscribe(path => ModListFile.Load(path))
.DisposeWith(disposables);
this.Bind(ViewModel, x => x.Download,
view => view.DownloadPath.SelectedPath)
ViewModel.WhenAnyValue(vm => vm.ModListPath)
.Subscribe(path => ModListFile.Load(path))
.DisposeWith(disposables);
this.Bind(ViewModel, x => x.Install,
view => view.InstallPath.SelectedPath)
ViewModel.WhenAnyValue(vm => vm.Download)
.Subscribe(path => DownloadPath.Load(path))
.DisposeWith(disposables);
ViewModel.WhenAnyValue(vm => vm.Install)
.Subscribe(path => InstallPath.Load(path))
.DisposeWith(disposables);
ViewModel.WhenAnyValue(x => x.BeginCommand)
.Where(x => x != default)
.BindTo(BeginInstall, x => x.Button.Command)
this.WhenAnyValue(view => view.ModListFile.SelectedPath)
.BindTo(ViewModel, vm => vm.ModListPath)
.DisposeWith(disposables);
ViewModel.WhenAnyValue(x => x.ModList)
.Where(x => x != default)
.Select(x => x!.Name)
.BindTo(ModListName, x => x.Text)
this.WhenAnyValue(view => view.DownloadPath.SelectedPath)
.BindTo(ViewModel, vm => vm.Download)
.DisposeWith(disposables);
ViewModel.WhenAnyValue(x => x.ModListImage)
.Where(x => x != default)
.BindTo(ModListImage, x => x.Source)
this.WhenAnyValue(view => view.InstallPath.SelectedPath)
.BindTo(ViewModel, vm => vm.Install)
.DisposeWith(disposables);
});
}