当前位置: 首页 > 编程语言 > C#

Couldnotfindtypeornamespacename(XAMLnewfunction)share

时间:2023-04-10 14:48:53 C#

couldnotfindtypeornamespacename(XAMLnewfunction)所以我尝试用VisualStudio2012在XAML文档上使用一个很简单骰子应用程序,但我不知道如何处理错误。我尝试添加位图图像;但它仍然不起作用。下面是我得到的错误:Error1Undefinednamespace。“正在使用”的URI引用了一个无法找到的命名空间“DiceRoll”。错误2找不到类型或命名空间名称“BitmapImage”(是否缺少using指令或程序集引用?)CS:usingSystem;使用System.Collections.Generic;使用System.IO;使用System.Linq;使用Windows.Foundation;使用Windows.Foundation.Collections;使用Windows.UI.Xaml;使用Windows.UI.Xaml.Controls;使用Windows.UI.Xaml.Controls.Primitives;使用Windows.UI.Xaml.Data;使用Windows.UI.Xaml.Input;使用Windows.UI.Xaml.Media;使用Windows.UI.Xaml.Navigation;使用位图图像;//空白页面项模板记录在http://go.microsoft.com/fwlink/?LinkId=234238namespaceDiceRoll{//////MainWindow.xaml的交互逻辑///publicpartialclassMainPage:Page{publicMainPage(){InitializeComponent();}privatevoidbutton1_Click(objectsender,RoutedEventArgse){Randomnum=new随机数();intNumber=num.Next(1,7);BitmapImageImg=newBitmapImage(newUri(@"DiceFaces"+Number.ToString()+".bmp",UriKind.Relative));textBlock1.Text=Number.ToString()+"Number";image1.Source=Img;XAML:尝试使用System.Windows.Media.Imaging.BitmapImage;而不是使用BitmapImage;更简单的方法是让VisualStudioforYou完成:右键单击代码中的BitmapImage->解析,然后选择正确的命名空间(通常只有一个)对于xaml,让VisualStudio也为您完成,或者:所有的空间名分享的内容(XAML新功能),如果对你有用,需要了解更多C#学习教程,希望大家多多关注。本文收集自网络,不代表立场。如涉及侵权,请点击维权联系管理员删除,如有转载请注明出处: