diff --git a/demo/Ursa.Demo.Android/App.axaml.cs b/demo/Ursa.Demo.Android/App.axaml.cs deleted file mode 100644 index 61508ce..0000000 --- a/demo/Ursa.Demo.Android/App.axaml.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Avalonia; -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Markup.Xaml; -using Ursa.Demo.Views; - -namespace Ursa.Demo.Android; - -public partial class App : Application -{ - public override void Initialize() - { - AvaloniaXamlLoader.Load(this); - } - - public override void OnFrameworkInitializationCompleted() - { - if (ApplicationLifetime is ISingleViewApplicationLifetime single) - { - single.MainView = new MainView(); - } - base.OnFrameworkInitializationCompleted(); - } -} \ No newline at end of file diff --git a/demo/Ursa.Demo.Browser/App.axaml b/demo/Ursa.Demo.Browser/App.axaml deleted file mode 100644 index 94b6bbf..0000000 --- a/demo/Ursa.Demo.Browser/App.axaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/demo/Ursa.Demo.Browser/App.axaml.cs b/demo/Ursa.Demo.Browser/App.axaml.cs deleted file mode 100644 index 9c680b0..0000000 --- a/demo/Ursa.Demo.Browser/App.axaml.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Avalonia; -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Markup.Xaml; -using Ursa.Demo.Views; - -namespace Ursa.Demo.Browser; - -public partial class App : Application -{ - public override void Initialize() - { - AvaloniaXamlLoader.Load(this); - } - - public override void OnFrameworkInitializationCompleted() - { - if (ApplicationLifetime is ISingleViewApplicationLifetime single) - { - single.MainView = new MainView(); - } - base.OnFrameworkInitializationCompleted(); - } -} \ No newline at end of file diff --git a/demo/Ursa.Demo.Desktop/App.axaml b/demo/Ursa.Demo.Desktop/App.axaml deleted file mode 100644 index 5873771..0000000 --- a/demo/Ursa.Demo.Desktop/App.axaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj b/demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj index 1ff2d0a..3d3f388 100644 --- a/demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj +++ b/demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj @@ -3,7 +3,7 @@ WinExe - net6.0 + net7.0 enable true @@ -21,11 +21,4 @@ - - - - App.axaml - Code - - diff --git a/demo/Ursa.Demo.iOS/AppDelegate.cs b/demo/Ursa.Demo.iOS/AppDelegate.cs index 0eb6c00..a565165 100644 --- a/demo/Ursa.Demo.iOS/AppDelegate.cs +++ b/demo/Ursa.Demo.iOS/AppDelegate.cs @@ -4,7 +4,6 @@ using Avalonia; using Avalonia.Controls; using Avalonia.iOS; using Avalonia.Media; -using Avalonia.ReactiveUI; namespace Ursa.Demo.iOS; @@ -16,8 +15,6 @@ public partial class AppDelegate : AvaloniaAppDelegate { protected override AppBuilder CustomizeAppBuilder(AppBuilder builder) { - return base.CustomizeAppBuilder(builder) - .WithInterFont() - .UseReactiveUI(); + return base.CustomizeAppBuilder(builder); } } \ No newline at end of file diff --git a/demo/Ursa.Demo.Android/App.axaml b/demo/Ursa.Demo/App.axaml similarity index 90% rename from demo/Ursa.Demo.Android/App.axaml rename to demo/Ursa.Demo/App.axaml index 2b8c798..8326f56 100644 --- a/demo/Ursa.Demo.Android/App.axaml +++ b/demo/Ursa.Demo/App.axaml @@ -1,5 +1,5 @@ diff --git a/demo/Ursa.Demo.Desktop/App.axaml.cs b/demo/Ursa.Demo/App.axaml.cs similarity index 59% rename from demo/Ursa.Demo.Desktop/App.axaml.cs rename to demo/Ursa.Demo/App.axaml.cs index 66b6de0..169a116 100644 --- a/demo/Ursa.Demo.Desktop/App.axaml.cs +++ b/demo/Ursa.Demo/App.axaml.cs @@ -4,7 +4,7 @@ using Avalonia.Markup.Xaml; using Ursa.Demo.ViewModels; using Ursa.Demo.Views; -namespace Ursa.Demo.Desktop; +namespace Ursa.Demo; public partial class App : Application { @@ -17,11 +17,16 @@ public partial class App : Application { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - // Line below is needed to remove Avalonia data validation. - // Without this line you will get duplicate validations from both Avalonia and CT - desktop.MainWindow = new MainWindow + desktop.MainWindow = new MainWindow() { - DataContext = new MainWindowViewModel(), + DataContext = new MainViewViewModel(), + }; + } + else if (ApplicationLifetime is ISingleViewApplicationLifetime singleView) + { + singleView.MainView = new MainView() + { + DataContext = new MainViewViewModel(), }; } diff --git a/demo/Ursa.Demo/Ursa.Demo.csproj b/demo/Ursa.Demo/Ursa.Demo.csproj index 4f0188d..5f47fa7 100644 --- a/demo/Ursa.Demo/Ursa.Demo.csproj +++ b/demo/Ursa.Demo/Ursa.Demo.csproj @@ -26,4 +26,11 @@ + + + + App.axaml + Code + + diff --git a/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs b/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs new file mode 100644 index 0000000..6641f1f --- /dev/null +++ b/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs @@ -0,0 +1,39 @@ +using CommunityToolkit.Mvvm.Messaging; + +namespace Ursa.Demo.ViewModels; + +public class MainViewViewModel : ViewModelBase +{ + public MenuViewModel Menus { get; set; } = new MenuViewModel(); + + private object? _content; + + public object? Content + { + get => _content; + set => SetProperty(ref _content, value); + } + + public MainViewViewModel() + { + WeakReferenceMessenger.Default.Register(this, OnNavigation); + } + + + private void OnNavigation(MainViewViewModel vm, string s) + { + Content = s switch + { + MenuKeys.MenuKeyBadge => new BadgeDemoViewModel(), + MenuKeys.MenuKeyBanner => new BannerDemoViewModel(), + MenuKeys.MenuKeyButtonGroup => new ButtonGroupDemoViewModel(), + MenuKeys.MenuKeyDivider => new DividerDemoViewModel(), + MenuKeys.MenuKeyIpBox => new IPv4BoxDemoViewModel(), + MenuKeys.MenuKeyLoading => new LoadingDemoViewModel(), + MenuKeys.MenuKeyNavigation => new NavigationMenuDemoViewModel(), + MenuKeys.MenuKeyPagination => new PaginationDemoViewModel(), + MenuKeys.MenuKeyTagInput => new TagInputDemoViewModel(), + MenuKeys.MenuKeyTimeline => new TimelineDemoViewModel(), + }; + } +} \ No newline at end of file diff --git a/demo/Ursa.Demo/ViewModels/MainWindowViewModel.cs b/demo/Ursa.Demo/ViewModels/MainWindowViewModel.cs index 7fdbd75..522e47b 100644 --- a/demo/Ursa.Demo/ViewModels/MainWindowViewModel.cs +++ b/demo/Ursa.Demo/ViewModels/MainWindowViewModel.cs @@ -1,40 +1,6 @@ - -using CommunityToolkit.Mvvm.Messaging; - -namespace Ursa.Demo.ViewModels; +namespace Ursa.Demo.ViewModels; public class MainWindowViewModel : ViewModelBase { - public MenuViewModel Menus { get; set; } = new MenuViewModel(); - - private object? _content; - public object? Content - { - get => _content; - set => SetProperty(ref _content, value); - } - - public MainWindowViewModel() - { - WeakReferenceMessenger.Default.Register(this, OnNavigation); - } - - - - private void OnNavigation(MainWindowViewModel vm, string s) - { - Content = s switch - { - MenuKeys.MenuKeyBadge => new BadgeDemoViewModel(), - MenuKeys.MenuKeyBanner => new BannerDemoViewModel(), - MenuKeys.MenuKeyButtonGroup => new ButtonGroupDemoViewModel(), - MenuKeys.MenuKeyDivider => new DividerDemoViewModel(), - MenuKeys.MenuKeyIpBox => new IPv4BoxDemoViewModel(), - MenuKeys.MenuKeyLoading => new LoadingDemoViewModel(), - MenuKeys.MenuKeyNavigation => new NavigationMenuDemoViewModel(), - MenuKeys.MenuKeyPagination => new PaginationDemoViewModel(), - MenuKeys.MenuKeyTagInput => new TagInputDemoViewModel(), - MenuKeys.MenuKeyTimeline => new TimelineDemoViewModel(), - }; - } + public MainViewViewModel MainViewViewModel { get; set; } = new MainViewViewModel(); } \ No newline at end of file diff --git a/demo/Ursa.Demo/Views/MainView.axaml b/demo/Ursa.Demo/Views/MainView.axaml index 1183ce5..710026c 100644 --- a/demo/Ursa.Demo/Views/MainView.axaml +++ b/demo/Ursa.Demo/Views/MainView.axaml @@ -10,11 +10,11 @@ d:DesignHeight="450" d:DesignWidth="800" x:CompileBindings="True" - x:DataType="vm:MainWindowViewModel" + x:DataType="vm:MainViewViewModel" mc:Ignorable="d"> - + diff --git a/demo/Ursa.Demo/Views/MainWindow.axaml b/demo/Ursa.Demo/Views/MainWindow.axaml index 24c7b85..054e043 100644 --- a/demo/Ursa.Demo/Views/MainWindow.axaml +++ b/demo/Ursa.Demo/Views/MainWindow.axaml @@ -5,10 +5,13 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:views="clr-namespace:Ursa.Demo.Views" + xmlns:viewModels="clr-namespace:Ursa.Demo.ViewModels" Title="Ursa.Demo" d:DesignHeight="450" d:DesignWidth="800" + x:CompileBindings="True" + x:DataType="viewModels:MainWindowViewModel" Icon="/Assets/Ursa.ico" mc:Ignorable="d"> - + \ No newline at end of file