diff --git a/BlazorDemo/App.axaml.cs b/BlazorDemo/App.axaml.cs index 1898d7d..6e1e91c 100644 --- a/BlazorDemo/App.axaml.cs +++ b/BlazorDemo/App.axaml.cs @@ -9,7 +9,7 @@ namespace BlazorDemo { public partial class App : Application { - public static IInputDialogService? InputDialogService { get; set;} + public static IInputDialogService? InputDialogService { get; set; } public override void Initialize() { diff --git a/BlazorDemo/ViewModels/FileViewModel.cs b/BlazorDemo/ViewModels/FileViewModel.cs new file mode 100644 index 0000000..ae80a9e --- /dev/null +++ b/BlazorDemo/ViewModels/FileViewModel.cs @@ -0,0 +1,28 @@ +using ReactiveUI; + +namespace BlazorDemo.ViewModels +{ + public class FileViewModel : ViewModelBase + { + private string _name; + private string _contents; + + public string Name + { + get => _name; + set => this.RaiseAndSetIfChanged(ref _name, value); + } + + public string Contents + { + get => _contents; + set => this.RaiseAndSetIfChanged(ref _contents, value); + } + + public FileViewModel(string name, string contents) + { + _name = name; + _contents = contents; + } + } +} diff --git a/BlazorDemo/ViewModels/MainViewModel.cs b/BlazorDemo/ViewModels/MainViewModel.cs index d9a58df..87c907d 100644 --- a/BlazorDemo/ViewModels/MainViewModel.cs +++ b/BlazorDemo/ViewModels/MainViewModel.cs @@ -1,11 +1,28 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.ObjectModel; +using ReactiveUI; namespace BlazorDemo.ViewModels { public class MainViewModel : ViewModelBase { - public string Greeting => "Welcome to Avalonia!"; + private FileViewModel? _selectedFile; + private ObservableCollection _files; + + public FileViewModel? SelectedFile + { + get => _selectedFile; + set => this.RaiseAndSetIfChanged(ref _selectedFile, value); + } + + public ObservableCollection Files + { + get => _files; + set => this.RaiseAndSetIfChanged(ref _files, value); + } + + public MainViewModel() + { + _files = new ObservableCollection(); + } } } diff --git a/BlazorDemo/Views/MainView.axaml b/BlazorDemo/Views/MainView.axaml index 41ca701..c249474 100644 --- a/BlazorDemo/Views/MainView.axaml +++ b/BlazorDemo/Views/MainView.axaml @@ -12,29 +12,41 @@ - -