[UWP]失踪; XAML文件中的错误 [英] [UWP]Missing ; error in a XAML file

查看:85
本文介绍了[UWP]失踪; XAML文件中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UWP XAML页面中收到此Build错误。

I get this Build error in UWP XAML page.

< Button Content =" Button"的Horizo​​ntalAlignment = QUOT;左"

         Click =" System.Threading.Tasks.Task Button_ClickAsync"余量= QUOT; 700,553,0,0" VerticalAlignment =" Top" />

<Button Content="Button" HorizontalAlignment="Left"
         Click="System.Threading.Tasks.Task Button_ClickAsync" Margin="700,553,0,0" VerticalAlignment="Top"/>

这是我得到的错误:

严重程度  ;代码 说明 项目 文件 行 抑制状态

错误  CS1002  ;;预计&NBSP; J_JSON&NBSP; C:\Users\Owner\source\repos\J_JSON\J_JSON\MainPage.xaml&NBSP; 13 有效

Severity Code Description Project File Line Suppression State
Error CS1002 ; expected  J_JSON C:\Users\Owner\source\repos\J_JSON\J_JSON\MainPage.xaml  13 Active

XAML第13行的按钮代码

XAML Button code on Line 13

Jayaram Krishnaswamy

Jayaram Krishnaswamy

推荐答案

Hello jkrishnaswamy,

Hello jkrishnaswamy,

Button.Click 仅接受RoutedEventHandler。您不能设置任何其他类型的委托。正确设计事件处理函数
以避免问题。 

Button.Click only accepts RoutedEventHandler. You cannot set any other kinds of delegates. Design the event handler function correctly to avoid the issue. 

例如。 XAML:

<Button Content="Button" Click="Button_Click"/>


和C#:

and C#:

void Button_Click(object sender, RoutedEventArgs e)
{
    
}

附录:之所以为"CS1002;预期"错误显示。

Appendix: The reason why "CS1002 ; expected" error is shown.

Visual Studio从MainPage.xaml生成MainPage.g.cs并尝试编译它以生成处理事件所需的执行代码。然后,您的XAML中的Button.Click将在MainPage.g.cs中产生  ...

Visual Studio generates MainPage.g.cs from MainPage.xaml and tries to compile it to make execution code required to handle events. Then, the Button.Click in your XAML would yield ...

C#代码:

((global::Windows.UI.Xaml.Controls.Button)element1).Click += this.System.Threading.Tasks.Task Button_ClickAsync;


显然它缺少";"。在语法中。所以它会导致错误。尝试在 "obj"中查看实际的MainPage.g.cs文件。项目中的文件夹。

Apparently it lacks ";" in syntax. So it causes that error. Try looking into the actual MainPage.g.cs file in the "obj" folder in your project.


这篇关于[UWP]失踪; XAML文件中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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