如何在C#中的WPF之间链接页面? [英] How to link pages between WPF in C#?

查看:61
本文介绍了如何在C#中的WPF之间链接页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。

首先,我很抱歉,也许我问的是一个非常简单和荒谬的问题。我想做一个wpf项目。



第1页:将包含用户名和密码。

我这样做了如下。但是我想保留一个数据库。

所以我准备了一个ID为DbPerson的表,用户名和密码。我该怎么做。



第2页:如果页面正在添加记录,则会有删除。

但是我无法切换到第2页。我应该如何设计新模型,查看和查看模型。



你能帮我这个吗?



我尝试过:



MainWindow.xmal

Hello.
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:

MainWindow.xmal

<Window x:Class="MyFirstWpfProject.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:MyFirstWpfProject"
        mc:Ignorable="d"
        Title="User Input Panel" Height="600.197" Width="1000.605" Background="DarkGray" FontFamily="Times New Roman" FontSize="30" FontStyle="Oblique">
    <Grid>
        <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"/>

    </Grid>
</Window>





MainWindow.xmal.cs





MainWindow.xmal.cs

public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

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

            if (username == "A" && password == "1")
            {
               
                MessageBox.Show("Successfull");

            }
            else
            {
                MessageBox.Show("Username or password error.");
            }

        }
    }

推荐答案

这不是一个问题,那是一个问题申请。



使用WPF和Entity Framework 6创建一个简单的数据应用程序 - Visual Studio | Microsoft Docs [ ^ ]
That's not a question, that's an application.

Create a simple data application with WPF and Entity Framework 6 - Visual Studio | Microsoft Docs[^]


这篇关于如何在C#中的WPF之间链接页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆