using Avalonia; using Avalonia.Controls; using Avalonia.Interactivity; using Avalonia.Markup.Xaml; using AvaloniaApplication2.ViewModels; using System; namespace AvaloniaApplication2.Views; public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); void button1_Click(object sender, RoutedEventArgs e) { String allowchar = " "; allowchar = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"; allowchar += "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,y,z"; allowchar += "1,2,3,4,5,6,7,8,9,0"; char[] a = { ',' }; String[] ar = allowchar.Split(a); String pwd = " "; string temp = " "; Random r = new Random(); for (int i = 0; i < 6; i++) { temp = ar[(r.Next(0, ar.Length))]; pwd += temp; } textBox1.Text = pwd; } } }