Click here to Skip to main content
14,487,848 members

How to link pages between WPF in C#?

StudentSC asked:

Open original thread
First of all, I'm sorry, maybe I'm asking a very simple and absurd question.I want to do one wpf project.

Page 1: will contain username and password.
I have done this as follows. But I want to keep a database.
So I prepared a table with Id, User name and password as DbPerson. How do I do this.

Page 2: If the page is adding records, there will be deletions.
But I could not switch to page 2. How should I design a new model, view and view model.

Can you help me with this?

What I have tried:

<Window x:Class="MyFirstWpfProject.MainWindow"
        Title="User Input Panel" Height="600.197" Width="1000.605" Background="DarkGray" FontFamily="Times New Roman" FontSize="30" FontStyle="Oblique">
        <Button x:Name="button" Content="Save" Command="{Binding SaveCommand}" HorizontalAlignment="Left" Margin="330,447,0,0" VerticalAlignment="Top" Width="324" Height="64" FontFamily="Times New Roman" Foreground="Black" FontSize="30" Click="btnSave" />
        <Label x:Name="label" Content="Username:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="191,160,0,0" Height="70" Width="211" FontSize="30" FontFamily="Times New Roman" FontStyle="Italic"/>
        <Label x:Name="label1" Content="Password" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="191,282,0,0" Height="42" Width="149" FontSize="30" FontFamily="Times New Roman" FontStyle="Italic"/>
        <TextBox x:Name="txtusername" HorizontalAlignment="Left" Height="41" TextWrapping="Wrap"  VerticalAlignment="Top" Width="226" Margin="470,160,0,0"/>
        <TextBox x:Name="txtpassword" HorizontalAlignment="Left" Height="42" TextWrapping="Wrap" VerticalAlignment="Top" Width="226" Margin="470,282,0,0"/>
        <StackPanel Name="MyStackPanel"   HorizontalAlignment="Left" Height="559" VerticalAlignment="Top" Width="983"/>



public partial class MainWindow : Window
        public MainWindow()

        private void btnSave(object sender, RoutedEventArgs e)
            string username = txtusername.Text;
            string password = txtpassword.Text;

            if (username == "A" && password == "1")

                MessageBox.Show("Username or password error.");



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100