Skip to content

Commit

Permalink
Add ReactiveUI demo
Browse files Browse the repository at this point in the history
  • Loading branch information
wieslawsoltes committed Nov 19, 2024
1 parent a460e58 commit fb68992
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 31 deletions.
41 changes: 28 additions & 13 deletions ReactiveGeneratorDemo/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,37 @@
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"
xmlns:inpcDemo="clr-namespace:ReactiveGeneratorDemo"
xmlns:viewModels="clr-namespace:ReactiveGeneratorDemo.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ReactiveGeneratorDemo.MainWindow"
Title="ReactiveGeneratorDemo"
Width="500" Height="400" WindowStartupLocation="CenterScreen"
x:DataType="inpcDemo:Person" x:CompileBindings="True">
<StackPanel Spacing="10">
<StackPanel Spacing="10">
<TextBox Text="{Binding FirstName}" />
<TextBox Text="{Binding LastName}" />
<TextBox Text="{Binding Age}" />
</StackPanel>
<StackPanel Spacing="10">
<TextBlock Text="{Binding FirstName}" />
<TextBlock Text="{Binding LastName}" />
<TextBlock Text="{Binding Age}" />
</StackPanel>
x:DataType="viewModels:Test" x:CompileBindings="True">
<StackPanel>

<StackPanel Spacing="10" DataContext="{Binding Person}">
<TextBlock Text="Person" />
<StackPanel Spacing="10">
<TextBox Text="{Binding FirstName}" />
<TextBox Text="{Binding LastName}" />
<TextBox Text="{Binding Age}" />
</StackPanel>
<StackPanel Spacing="10">
<TextBlock Text="{Binding FirstName}" />
<TextBlock Text="{Binding LastName}" />
<TextBlock Text="{Binding Age}" />
</StackPanel>
</StackPanel>

<StackPanel Spacing="10" DataContext="{Binding Car}">
<TextBlock Text="Car" />
<StackPanel Spacing="10">
<TextBox Text="{Binding Make}" />
</StackPanel>
<StackPanel Spacing="10">
<TextBlock Text="{Binding Make}" />
</StackPanel>
</StackPanel>

</StackPanel>
</Window>
11 changes: 8 additions & 3 deletions ReactiveGeneratorDemo/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Avalonia.Controls;
using ReactiveGeneratorDemo.ViewModels;

namespace ReactiveGeneratorDemo;

Expand All @@ -8,8 +9,12 @@ public MainWindow()
{
InitializeComponent();

var person = new Person { FirstName = "John", LastName = "Doe", Age = 30 };

DataContext = person;
var test = new Test
{
Person = new Person { FirstName = "John", LastName = "Doe", Age = 30 },
Car = new Car { Make = "Toyota" }
};

DataContext = test;
}
}
2 changes: 2 additions & 0 deletions ReactiveGeneratorDemo/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Avalonia;
using System;
using Avalonia.ReactiveUI;

namespace ReactiveGeneratorDemo;

Expand All @@ -16,6 +17,7 @@ public static void Main(string[] args) => BuildAvaloniaApp()
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.UseReactiveUI()
.WithInterFont()
.LogToTrace();
}
1 change: 1 addition & 0 deletions ReactiveGeneratorDemo/ReactiveGeneratorDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.1.0"/>
<PackageReference Include="Avalonia.Desktop" Version="11.1.0"/>
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.0" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.0"/>
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.0"/>
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
Expand Down
9 changes: 9 additions & 0 deletions ReactiveGeneratorDemo/ViewModels/Car.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using ReactiveUI;

namespace ReactiveGeneratorDemo.ViewModels;

public partial class Car : ReactiveObject
{
[Reactive]
public partial string Make { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;

namespace ReactiveGeneratorDemo;
namespace ReactiveGeneratorDemo.ViewModels;

public partial class Person
{
Expand All @@ -16,15 +14,3 @@ public partial class Person
[Reactive]
internal partial string Tag { get; private set; }
}

public partial class Student : Person
{
[Reactive]
public partial string Address { get; set; }
}

public partial class Teacher : Person
{
[Reactive]
public partial List<Student> Students { get; set; }
}
7 changes: 7 additions & 0 deletions ReactiveGeneratorDemo/ViewModels/Student.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace ReactiveGeneratorDemo.ViewModels;

public partial class Student : Person
{
[Reactive]
public partial string Address { get; set; }
}
9 changes: 9 additions & 0 deletions ReactiveGeneratorDemo/ViewModels/Teacher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace ReactiveGeneratorDemo.ViewModels;

public partial class Teacher : Person
{
[Reactive]
public partial List<Student> Students { get; set; }
}
10 changes: 10 additions & 0 deletions ReactiveGeneratorDemo/ViewModels/Test.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace ReactiveGeneratorDemo.ViewModels;

public partial class Test
{
[Reactive]
public partial Person Person { get; set; }

[Reactive]
public partial Car Car { get; set; }
}

0 comments on commit fb68992

Please sign in to comment.