Browse Source
* fix: Name Generation for Identical View Class Names * nit: Formattingpull/10407/head
committed by
GitHub
16 changed files with 173 additions and 193 deletions
@ -0,0 +1,38 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:controls="clr-namespace:Avalonia.NameGenerator.Sandbox.Controls" |
|||
x:Class="Avalonia.NameGenerator.Sandbox.Controls.SignUpView"> |
|||
<StackPanel> |
|||
<controls:CustomTextBox Margin="0 10 0 0" |
|||
x:Name="UserNameTextBox" |
|||
Watermark="Please, enter user name..." |
|||
UseFloatingWatermark="True" /> |
|||
<TextBlock x:Name="UserNameValidation" |
|||
Foreground="Red" |
|||
FontSize="12" /> |
|||
<TextBox Margin="0 10 0 0" |
|||
x:Name="PasswordTextBox" |
|||
Watermark="Please, enter your password..." |
|||
UseFloatingWatermark="True" |
|||
PasswordChar="*" /> |
|||
<TextBlock x:Name="PasswordValidation" |
|||
Foreground="Red" |
|||
FontSize="12" /> |
|||
<TextBox Margin="0 10 0 0" |
|||
x:Name="ConfirmPasswordTextBox" |
|||
Watermark="Please, confirm the password..." |
|||
UseFloatingWatermark="True" |
|||
PasswordChar="*" /> |
|||
<TextBlock x:Name="ConfirmPasswordValidation" |
|||
TextWrapping="Wrap" |
|||
Foreground="Red" |
|||
FontSize="12" /> |
|||
<Button Margin="0 10 0 5" |
|||
Content="Sign up" |
|||
x:Name="SignUpButton" /> |
|||
<TextBlock x:Name="CompoundValidation" |
|||
TextWrapping="Wrap" |
|||
Foreground="Red" |
|||
FontSize="12" /> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,53 @@ |
|||
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"; |
|||
}); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue