diff options
Diffstat (limited to 'JVDesktop')
| -rw-r--r-- | JVDesktop/App.axaml | 4 | ||||
| -rw-r--r-- | JVDesktop/App.axaml.cs | 4 | ||||
| -rw-r--r-- | JVDesktop/JVDesktop.csproj | 2 | ||||
| -rw-r--r-- | JVDesktop/ViewLocator.cs | 5 | ||||
| -rw-r--r-- | JVDesktop/ViewModels/MainWindowViewModel.cs | 15 | ||||
| -rw-r--r-- | JVDesktop/Views/MainWindow.axaml | 5 |
6 files changed, 23 insertions, 12 deletions
diff --git a/JVDesktop/App.axaml b/JVDesktop/App.axaml index 24e82f2..4d268d0 100644 --- a/JVDesktop/App.axaml +++ b/JVDesktop/App.axaml @@ -8,8 +8,8 @@ <Application.DataTemplates> <local:ViewLocator/> </Application.DataTemplates> - + <Application.Styles> <FluentTheme /> </Application.Styles> -</Application>
\ No newline at end of file +</Application> diff --git a/JVDesktop/App.axaml.cs b/JVDesktop/App.axaml.cs index b1bc4c0..4c26724 100644 --- a/JVDesktop/App.axaml.cs +++ b/JVDesktop/App.axaml.cs @@ -20,7 +20,7 @@ public partial class App : Application { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - // Avoid duplicate validations from both Avalonia and the CommunityToolkit. + // Avoid duplicate validations from both Avalonia and the CommunityToolkit. // More info: https://docs.avaloniaui.net/docs/guides/development-guides/data-validation#manage-validationplugins DisableAvaloniaDataAnnotationValidation(); desktop.MainWindow = new MainWindow @@ -44,4 +44,4 @@ public partial class App : Application BindingPlugins.DataValidators.Remove(plugin); } } -}
\ No newline at end of file +} diff --git a/JVDesktop/JVDesktop.csproj b/JVDesktop/JVDesktop.csproj index 5ba2c97..e103899 100644 --- a/JVDesktop/JVDesktop.csproj +++ b/JVDesktop/JVDesktop.csproj @@ -1,7 +1,7 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>WinExe</OutputType> - <TargetFramework>net9.0</TargetFramework> + <TargetFramework>net8.0</TargetFramework> <Nullable>enable</Nullable> <BuiltInComInteropSupport>true</BuiltInComInteropSupport> <ApplicationManifest>app.manifest</ApplicationManifest> diff --git a/JVDesktop/ViewLocator.cs b/JVDesktop/ViewLocator.cs index f289d15..6015998 100644 --- a/JVDesktop/ViewLocator.cs +++ b/JVDesktop/ViewLocator.cs @@ -7,12 +7,11 @@ namespace JVDesktop; public class ViewLocator : IDataTemplate { - public Control? Build(object? param) { if (param is null) return null; - + var name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal); var type = Type.GetType(name); @@ -20,7 +19,7 @@ public class ViewLocator : IDataTemplate { return (Control)Activator.CreateInstance(type)!; } - + return new TextBlock { Text = "Not Found: " + name }; } diff --git a/JVDesktop/ViewModels/MainWindowViewModel.cs b/JVDesktop/ViewModels/MainWindowViewModel.cs index 0ca52c8..4dd12b4 100644 --- a/JVDesktop/ViewModels/MainWindowViewModel.cs +++ b/JVDesktop/ViewModels/MainWindowViewModel.cs @@ -1,6 +1,15 @@ -namespace JVDesktop.ViewModels; +using System; +using System.Windows.Input; +using CommunityToolkit.Mvvm.Input; -public partial class MainWindowViewModel : ViewModelBase +namespace JVDesktop.ViewModels; + +public class MainWindowViewModel : ViewModelBase { - public string Greeting { get; } = "Welcome to Avalonia!"; + public string Greeting => "Welcome to Avalonia!"; + + public ICommand ButtonClickCommand { get; } = new RelayCommand(() => + { + Console.WriteLine("Button clicked"); + }); } diff --git a/JVDesktop/Views/MainWindow.axaml b/JVDesktop/Views/MainWindow.axaml index 9fb406d..13f20c4 100644 --- a/JVDesktop/Views/MainWindow.axaml +++ b/JVDesktop/Views/MainWindow.axaml @@ -15,6 +15,9 @@ <vm:MainWindowViewModel/> </Design.DataContext> - <TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/> + <Grid> + <TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/> + <Button Content="Click" Command="{Binding ButtonClickCommand}"/> + </Grid> </Window> |
