Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/examples/ReactiveUI.Samples.Maui/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public partial class App : Application

/// <inheritdoc/>
protected override Window CreateWindow(IActivationState? activationState) =>
new(new NavigationPage(new LoginPage()));
new(new AppShell());
}
13 changes: 13 additions & 0 deletions src/examples/ReactiveUI.Samples.Maui/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<Shell
x:Class="ReactiveUI.Samples.Maui.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ReactiveUI.Samples.Maui"
Shell.NavBarIsVisible="False">

<ShellContent
ContentTemplate="{DataTemplate local:LoginPage}"
Route="LoginPage" />

</Shell>
17 changes: 17 additions & 0 deletions src/examples/ReactiveUI.Samples.Maui/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

namespace ReactiveUI.Samples.Maui;

/// <summary>
/// Application shell providing Shell navigation for the MAUI sample.
/// </summary>
public partial class AppShell : Shell
{
/// <summary>
/// Initializes a new instance of the <see cref="AppShell"/> class.
/// </summary>
public AppShell() => InitializeComponent();
}
7 changes: 4 additions & 3 deletions src/examples/ReactiveUI.Samples.Maui/LoginPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ public LoginPage()
.DisposeWith(d);

ViewModel.Login
.Subscribe(async success =>
await (Shell.Current?.DisplayAlert(
.SelectMany(success => Observable.FromAsync(() =>
DisplayAlert(
success ? "Login Successful" : "Login Failed",
success ? "Welcome!" : "Invalid credentials.",
"OK") ?? Task.CompletedTask))
"OK")))
.Subscribe()
.DisposeWith(d);
});
}
Expand Down
10 changes: 8 additions & 2 deletions src/examples/ReactiveUI.Samples.Maui/LoginViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// See the LICENSE file in the project root for full license information.

using System.Reactive.Concurrency;
using System.Reactive.Subjects;

namespace ReactiveUI.Samples.Maui;

Expand All @@ -26,15 +27,20 @@ public LoginViewModel(IScheduler scheduler)
vm => vm.Password,
(user, pass) => !string.IsNullOrWhiteSpace(user) && !string.IsNullOrWhiteSpace(pass));

Cancel = ReactiveCommand.Create(() => { }, outputScheduler: scheduler);
var cancelSubject = new Subject<Unit>();

Login = ReactiveCommand.CreateFromObservable(
() => Observable
.Return(Password is "secret")
.Delay(TimeSpan.FromSeconds(1), scheduler)
.TakeUntil(Cancel),
.TakeUntil(cancelSubject),
canLogin,
scheduler);

Cancel = ReactiveCommand.Create(
() => cancelSubject.OnNext(Unit.Default),
Login.IsExecuting,
scheduler);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<TargetFrameworks>net10.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) or $([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net10.0-ios;net10.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net10.0-windows10.0.19041.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<UseMaui>true</UseMaui>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Expand All @@ -10,6 +13,18 @@
<IsAotCompatible>false</IsAotCompatible>
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
<EnableSingleFileAnalyzer>false</EnableSingleFileAnalyzer>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">24.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.19041.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.19041.0</TargetPlatformMinVersion>
</PropertyGroup>

<PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
<WindowsPackageType>None</WindowsPackageType>
<GenerateAppxPackageOnBuild>false</GenerateAppxPackageOnBuild>
<PublishAppxPackage>false</PublishAppxPackage>
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 8 additions & 2 deletions src/examples/ReactiveUI.Samples.Winforms/LoginViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// See the LICENSE file in the project root for full license information.

using System.Reactive.Concurrency;
using System.Reactive.Subjects;

namespace ReactiveUI.Samples.Winforms;

Expand All @@ -26,15 +27,20 @@ public LoginViewModel(IScheduler scheduler)
vm => vm.Password,
(user, pass) => !string.IsNullOrWhiteSpace(user) && !string.IsNullOrWhiteSpace(pass));

Cancel = ReactiveCommand.Create(() => { }, outputScheduler: scheduler);
var cancelSubject = new Subject<Unit>();

Login = ReactiveCommand.CreateFromObservable(
() => Observable
.Return(Password is "secret")
.Delay(TimeSpan.FromSeconds(1), scheduler)
.TakeUntil(Cancel),
.TakeUntil(cancelSubject),
canLogin,
scheduler);

Cancel = ReactiveCommand.Create(
() => cancelSubject.OnNext(Unit.Default),
Login.IsExecuting,
scheduler);
}

/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion src/examples/ReactiveUI.Samples.Wpf/LoginView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public LoginView()
.DisposeWith(d);

// WPF PasswordBox doesn't support data binding, so marshal changes manually.
Observable.FromEventPattern(Password, nameof(PasswordBox.PasswordChanged))
Observable.FromEventPattern<RoutedEventHandler, RoutedEventArgs>(
h => Password.PasswordChanged += h,
h => Password.PasswordChanged -= h)
.Select(_ => Password.Password)
.BindTo(this, v => v.ViewModel!.Password)
.DisposeWith(d);
Expand Down
10 changes: 8 additions & 2 deletions src/examples/ReactiveUI.Samples.Wpf/LoginViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// See the LICENSE file in the project root for full license information.

using System.Reactive.Concurrency;
using System.Reactive.Subjects;

namespace ReactiveUI.Samples.Wpf;

Expand All @@ -26,15 +27,20 @@ public LoginViewModel(IScheduler scheduler)
vm => vm.Password,
(user, pass) => !string.IsNullOrWhiteSpace(user) && !string.IsNullOrWhiteSpace(pass));

Cancel = ReactiveCommand.Create(() => { }, outputScheduler: scheduler);
var cancelSubject = new Subject<Unit>();

Login = ReactiveCommand.CreateFromObservable(
() => Observable
.Return(Password is "secret")
.Delay(TimeSpan.FromSeconds(1), scheduler)
.TakeUntil(Cancel),
.TakeUntil(cancelSubject),
canLogin,
scheduler);

Cancel = ReactiveCommand.Create(
() => cancelSubject.OnNext(Unit.Default),
Login.IsExecuting,
scheduler);
}

/// <summary>
Expand Down