-3
2 xaml 창이 있고 windows간에 데이터를 저장하고 싶습니다. 어떻게 할 수 있습니까?WPF 로그인 후 다른 xaml에 사용자 이름 저장
2 xaml 창이 있고 windows간에 데이터를 저장하고 싶습니다. 어떻게 할 수 있습니까?WPF 로그인 후 다른 xaml에 사용자 이름 저장
생성자를 사용하여 전달하는 방법은 아래 코드 샘플을 참조하십시오.
public partial class Login : Window
{
public Login()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Window1 win = new Window1(txtUsername.Text);
win.Show();
}
}
<Window x:Class="DelegateComd_Learning.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<TextBlock x:Name="txtDisplayUsername"/>
</Grid>
<Window x:Class="DelegateComd_Learning.Login"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Login" Height="300" Width="300">
<Grid>
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Username"/>
<TextBox x:Name="txtUsername" Width="100"/>
</StackPanel>
<Button Content="Login" Click="Button_Click"/>
</StackPanel>
</Grid>
public partial class Window1 : Window
{
public Window1(string username)
{
InitializeComponent();
txtDisplayUsername.Text = username;
}
}
굉장! 고마워 – user3793233
그 일을 여러 가지 방법이 있습니다. 다른 윈도우의 매개 변수로 생성자에 전달할 수 있습니다. –
xml/textbox에 글을 써야하나요? – user3793233