Added ReactiveUIDemo sample.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<ProjectConfiguration>
|
||||
<Settings>
|
||||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
|
||||
</Settings>
|
||||
</ProjectConfiguration>
|
||||
@@ -9,6 +9,7 @@
|
||||
"samples\\MiniMvvm\\MiniMvvm.csproj",
|
||||
"samples\\SampleControls\\ControlSamples.csproj",
|
||||
"samples\\Sandbox\\Sandbox.csproj",
|
||||
"samples\\ReactiveUIDemo\\ReactiveUIDemo.csproj",
|
||||
"src\\Avalonia.Base\\Avalonia.Base.csproj",
|
||||
"src\\Avalonia.Build.Tasks\\Avalonia.Build.Tasks.csproj",
|
||||
"src\\Avalonia.Controls.ColorPicker\\Avalonia.Controls.ColorPicker.csproj",
|
||||
|
||||
@@ -230,6 +230,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.Browser", "s
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.Browser.Blazor", "samples\ControlCatalog.Browser.Blazor\ControlCatalog.Browser.Blazor.csproj", "{90B08091-9BBD-4362-B712-E9F2CC62B218}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUIDemo", "samples\ReactiveUIDemo\ReactiveUIDemo.csproj", "{75C47156-C5D8-44BC-A5A7-E8657C2248D6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -541,6 +543,10 @@ Global
|
||||
{90B08091-9BBD-4362-B712-E9F2CC62B218}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{90B08091-9BBD-4362-B712-E9F2CC62B218}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{90B08091-9BBD-4362-B712-E9F2CC62B218}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{75C47156-C5D8-44BC-A5A7-E8657C2248D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{75C47156-C5D8-44BC-A5A7-E8657C2248D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{75C47156-C5D8-44BC-A5A7-E8657C2248D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{75C47156-C5D8-44BC-A5A7-E8657C2248D6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -605,6 +611,7 @@ Global
|
||||
{47F8530C-F19B-4B1A-B4D6-EB231522AE5D} = {86A3F706-DC3C-43C6-BE1B-B98F5BAAA268}
|
||||
{15B93A4C-1B46-43F6-B534-7B25B6E99932} = {9B9E3891-2366-4253-A952-D08BCEB71098}
|
||||
{90B08091-9BBD-4362-B712-E9F2CC62B218} = {9B9E3891-2366-4253-A952-D08BCEB71098}
|
||||
{75C47156-C5D8-44BC-A5A7-E8657C2248D6} = {9B9E3891-2366-4253-A952-D08BCEB71098}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {87366D66-1391-4D90-8999-95A620AD786A}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<Application
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="ReactiveUIDemo.App">
|
||||
<Application.Styles>
|
||||
<FluentTheme />
|
||||
</Application.Styles>
|
||||
</Application>
|
||||
@@ -0,0 +1,37 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
using ReactiveUI;
|
||||
using ReactiveUIDemo.ViewModels;
|
||||
using ReactiveUIDemo.Views;
|
||||
using Splat;
|
||||
|
||||
namespace ReactiveUIDemo
|
||||
{
|
||||
public class App : Application
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
Locator.CurrentMutable.Register(() => new FooView(), typeof(IViewFor<FooViewModel>));
|
||||
Locator.CurrentMutable.Register(() => new BarView(), typeof(IViewFor<BarViewModel>));
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
desktop.MainWindow = new MainWindow();
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
|
||||
public static int Main(string[] args)
|
||||
=> BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
||||
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
.UseReactiveUI()
|
||||
.LogToTrace();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
|
||||
x:Class="ReactiveUIDemo.MainWindow"
|
||||
xmlns:vm="using:ReactiveUIDemo.ViewModels"
|
||||
xmlns:rxui="using:Avalonia.ReactiveUI"
|
||||
Title="AvaloniaUI ReactiveUI Demo"
|
||||
x:DataType="vm:MainWindowViewModel">
|
||||
<TabControl TabStripPlacement="Left">
|
||||
<TabItem Header="RoutedViewHost">
|
||||
<DockPanel DataContext="{Binding RoutedViewHost}">
|
||||
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" Spacing="8">
|
||||
<Button Command="{Binding ShowFoo}">Foo</Button>
|
||||
<Button Command="{Binding ShowBar}">Bar</Button>
|
||||
</StackPanel>
|
||||
<rxui:RoutedViewHost Router="{Binding Router}"/>
|
||||
</DockPanel>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Window>
|
||||
@@ -0,0 +1,22 @@
|
||||
using ReactiveUIDemo.ViewModels;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ReactiveUIDemo
|
||||
{
|
||||
public class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.DataContext = new MainWindowViewModel();
|
||||
this.AttachDevTools();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
|
||||
<ProjectReference Include="..\..\src\Avalonia.ReactiveUI\Avalonia.ReactiveUI.csproj" />
|
||||
<ProjectReference Include="..\..\src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Views\BarView.axaml.cs">
|
||||
<DependentUpon>BarView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Views\FooView.axaml.cs">
|
||||
<DependentUpon>FooView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\..\build\SampleApp.props" />
|
||||
<Import Project="..\..\build\ReferenceCoreLibraries.props" />
|
||||
<Import Project="..\..\build\BuildTargets.targets" />
|
||||
<Import Project="..\..\build\Rx.props" />
|
||||
<Import Project="..\..\build\ReactiveUI.props" />
|
||||
</Project>
|
||||
@@ -0,0 +1,11 @@
|
||||
using ReactiveUI;
|
||||
|
||||
namespace ReactiveUIDemo.ViewModels
|
||||
{
|
||||
internal class BarViewModel : ReactiveObject, IRoutableViewModel
|
||||
{
|
||||
public BarViewModel(IScreen screen) => HostScreen = screen;
|
||||
public string UrlPathSegment => "Bar";
|
||||
public IScreen HostScreen { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using ReactiveUI;
|
||||
|
||||
namespace ReactiveUIDemo.ViewModels
|
||||
{
|
||||
internal class FooViewModel : ReactiveObject, IRoutableViewModel
|
||||
{
|
||||
public FooViewModel(IScreen screen) => HostScreen = screen;
|
||||
public string UrlPathSegment => "Foo";
|
||||
public IScreen HostScreen { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using ReactiveUI;
|
||||
|
||||
namespace ReactiveUIDemo.ViewModels
|
||||
{
|
||||
internal class MainWindowViewModel : ReactiveObject
|
||||
{
|
||||
public RoutedViewHostPageViewModel RoutedViewHost { get; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using ReactiveUI;
|
||||
|
||||
namespace ReactiveUIDemo.ViewModels
|
||||
{
|
||||
internal class RoutedViewHostPageViewModel : ReactiveObject, IScreen
|
||||
{
|
||||
public RoutedViewHostPageViewModel()
|
||||
{
|
||||
Foo = new(this);
|
||||
Bar = new(this);
|
||||
Router.Navigate.Execute(Foo);
|
||||
}
|
||||
|
||||
public RoutingState Router { get; } = new();
|
||||
public FooViewModel Foo { get; }
|
||||
public BarViewModel Bar { get; }
|
||||
|
||||
public void ShowFoo() => Router.Navigate.Execute(Foo);
|
||||
public void ShowBar() => Router.Navigate.Execute(Bar);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="ReactiveUIDemo.Views.BarView"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch">
|
||||
<Border Background="Blue">
|
||||
<TextBlock HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="48">
|
||||
Bar!
|
||||
</TextBlock>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,28 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ReactiveUI;
|
||||
using ReactiveUIDemo.ViewModels;
|
||||
|
||||
namespace ReactiveUIDemo.Views
|
||||
{
|
||||
internal partial class BarView : UserControl, IViewFor<BarViewModel>
|
||||
{
|
||||
public BarView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public BarViewModel? ViewModel { get; set; }
|
||||
|
||||
object? IViewFor.ViewModel
|
||||
{
|
||||
get => ViewModel;
|
||||
set => ViewModel = (BarViewModel?)value;
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="ReactiveUIDemo.Views.FooView"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch">
|
||||
<Border Background="Red">
|
||||
<TextBlock HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="48">
|
||||
Foo!
|
||||
</TextBlock>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,28 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ReactiveUI;
|
||||
using ReactiveUIDemo.ViewModels;
|
||||
|
||||
namespace ReactiveUIDemo.Views
|
||||
{
|
||||
internal partial class FooView : UserControl, IViewFor<FooViewModel>
|
||||
{
|
||||
public FooView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public FooViewModel? ViewModel { get; set; }
|
||||
|
||||
object? IViewFor.ViewModel
|
||||
{
|
||||
get => ViewModel;
|
||||
set => ViewModel = (FooViewModel?)value;
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user