本文介绍了学习WPF& C# - 第一天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我今天决定开始学习c#和wpf,并确信还会有100个帖子可以关注:)

我打算关注一些教程今晚在这里,但在我工作的时候,我想我会快速玩一下。

我创建了一个带有一些按钮的页面,每个按钮都会产生一个新的形式。

第一个按钮将始终有效,但是一旦我添加了几个按钮,我就会开始出错。



我可以解释为什么会这样吗?



Hi,
I have decided to start learning c# and wpf today and am sure there will be 100 more posts to follow :)
I plan to follow a few tutorials tonight on here but while I am at work I thought I would have a quick play around.
I have created a page with some buttons, each button is to spawn a new form.
The first button will always work but once i add several more I start getting errors.

Could I have an explanation as to why this is?

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

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Window win = new bapp();
            win.Show();
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            Window win = new Ulinks();
            win.Show();
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            Window win = new tasks();
            win.Show();
        }

        private void button4_Click(object sender, RoutedEventArgs e)
        {
            Window win = new settings();
            win.Show();
        }
    }
}







UPDATE 1



我收到所有其他按钮的以下错误



无法隐式转换类型''Dehub.Ulinks'' to''System.Windows.Window''C:\Development\c#\Dehub \Dehub \ MainWindow.xaml.cs 36 26 Dehub





更新2



这是Ulinks的XMAL




UPDATE 1

I get the following error for all other buttons

Cannot implicitly convert type ''Dehub.Ulinks'' to ''System.Windows.Window''C:\Development\c#\Dehub\Dehub\MainWindow.xaml.cs3626Dehub


UPDATE 2

Here is the XMAL of Ulinks

<Page x:Class="Dehub.Ulinks"

      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 

      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 

      mc:Ignorable="d" 

      d:DesignHeight="300" d:DesignWidth="300"

	Title="Ulinks">

    <Grid>

推荐答案



这篇关于学习WPF&amp; C# - 第一天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 08:54