csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
2.4 KiB
54 lines
2.4 KiB
using System;
|
|
using System.Reactive.Disposables;
|
|
using Avalonia.NameGenerator.Sandbox.ViewModels;
|
|
using Avalonia.ReactiveUI;
|
|
using ReactiveUI;
|
|
using ReactiveUI.Validation.Extensions;
|
|
using ReactiveUI.Validation.Formatters;
|
|
|
|
namespace Avalonia.NameGenerator.Sandbox.Controls;
|
|
|
|
/// <summary>
|
|
/// This is a sample view class with typed x:Name references generated using
|
|
/// .NET 5 source generators. The class has to be partial because x:Name
|
|
/// references are living in a separate partial class file. See also:
|
|
/// https://devblogs.microsoft.com/dotnet/new-c-source-generator-samples/
|
|
/// </summary>
|
|
public partial class SignUpView : ReactiveUserControl<SignUpViewModel>
|
|
{
|
|
public SignUpView()
|
|
{
|
|
// The InitializeComponent method is also generated automatically
|
|
// and lives in the autogenerated part of the partial class.
|
|
InitializeComponent();
|
|
this.WhenActivated(disposables =>
|
|
{
|
|
this.Bind(ViewModel, x => x.UserName, x => x.UserNameTextBox.Text)
|
|
.DisposeWith(disposables);
|
|
this.Bind(ViewModel, x => x.Password, x => x.PasswordTextBox.Text)
|
|
.DisposeWith(disposables);
|
|
this.Bind(ViewModel, x => x.ConfirmPassword, x => x.ConfirmPasswordTextBox.Text)
|
|
.DisposeWith(disposables);
|
|
this.BindCommand(ViewModel, x => x.SignUp, x => x.SignUpButton)
|
|
.DisposeWith(disposables);
|
|
|
|
this.BindValidation(ViewModel, x => x.UserName, x => x.UserNameValidation.Text)
|
|
.DisposeWith(disposables);
|
|
this.BindValidation(ViewModel, x => x.Password, x => x.PasswordValidation.Text)
|
|
.DisposeWith(disposables);
|
|
this.BindValidation(ViewModel, x => x.ConfirmPassword, x => x.ConfirmPasswordValidation.Text)
|
|
.DisposeWith(disposables);
|
|
|
|
var newLineFormatter = new SingleLineFormatter(Environment.NewLine);
|
|
this.BindValidation(ViewModel, x => x.CompoundValidation.Text, newLineFormatter)
|
|
.DisposeWith(disposables);
|
|
|
|
// The references to text boxes below are also auto generated.
|
|
// Use Ctrl+Click in order to view the generated sources.
|
|
UserNameTextBox.Text = "Joseph!";
|
|
PasswordTextBox.Text = "1234";
|
|
ConfirmPasswordTextBox.Text = "1234";
|
|
SignUpButtonDescription.Text = "Press the button below to sign up.";
|
|
});
|
|
}
|
|
}
|