Hello World [WPF](Hello World [WPF])
我正在尝试在WPF中创建我的hello world Windows应用程序。
我该怎么做才能运行这个窗口?
Class1.xaml
<Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> </Grid> </Window>
App.xaml中
<Application x:Class="App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Class1.xaml" > <Application.Resources> </Application.Resources> </Application>
Program.cs中
class Program { [STAThread] public static void Main() { new App().Run(); } }
我创建了一个空白sln并添加了这三个文件。 我还添加了WindowsBase,PresentationBase,PresentationFramework参考。
但该应用程序没有运行。
问题是什么?
I am trying to create my hello world windows app in WPF.
What should I do to run this window?
Class1.xaml
<Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> </Grid> </Window>
App.xaml
<Application x:Class="App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Class1.xaml" > <Application.Resources> </Application.Resources> </Application>
Program.cs
class Program { [STAThread] public static void Main() { new App().Run(); } }
I have created a blank sln and added these three files. I have also added WindowsBase, PresentationBase, PresentationFramework refs.
But the App is not running.
What is the problem?
原文:https://stackoverflow.com/questions/1147994
最满意答案
我关掉了如何检索文件夹。 我挑出了原因,如果无论第二次合并命中,Umbraco是否尝试检索文件夹,如果它为空,则返回该错误,这是b / c
无法将类型'Umbraco.Core.Dynamics.DynamicNull'转换为'Umbraco.Web.Models.DynamicPublishedContent'
因此,您必须将实际的媒体ID(有效)传递给
Umbraco.Media()
方法,否则您将返回此错误。public override ActionResult Index(RenderModel model) { var entries = this.GetContestEntries(this.GetCountryFolder(CurrentPage.GetProperty("contestMediaFolder").Value.ToString())); return base.Index(model); } public DynamicPublishedContent GetCountryFolder(string countryFolder) { return (DynamicPublishedContent)Umbraco.Media(countryFolder); } public List<WAR2015ContestModel> GetContestEntries(DynamicPublishedContent countryFolder) { ..... // code omitted }
I switched out how I retrieved the folder. I singled out the reason, and it's b/c if regardless if that 2nd coalesce hits, Umbraco attempts to retrieve the folder, and if it's null, it returns that error,
Cannot convert type 'Umbraco.Core.Dynamics.DynamicNull' to 'Umbraco.Web.Models.DynamicPublishedContent'
Therefore, you HAVE to pass an actual media id (that's valid) to the
Umbraco.Media()
method, or you'll have this error returned to you.public override ActionResult Index(RenderModel model) { var entries = this.GetContestEntries(this.GetCountryFolder(CurrentPage.GetProperty("contestMediaFolder").Value.ToString())); return base.Index(model); } public DynamicPublishedContent GetCountryFolder(string countryFolder) { return (DynamicPublishedContent)Umbraco.Media(countryFolder); } public List<WAR2015ContestModel> GetContestEntries(DynamicPublishedContent countryFolder) { ..... // code omitted }
相关问答
更多-
听起来像一个有趣的案例! 如果要迁移数据库中的项目(如文档类型,模板和宏),则很可能需要获取Courier等产品。 我可以看到,由于许可证成本,这对于拥有500多个站点的人来说可能是一个问题。 另一种选择可能是看看uSync ,看看它是否能满足您的需求。 我没有太多关于这个软件包的经验,但从它的外观来看,似乎它正在处理所有的数据库位 - 而其他一切(文件系统上的文件)将由你的应用程序处理,就像它现在一样。 Sounds like an interesting case! If you want to mig ...
-
Umbraco.Content返回动态。 您需要获取第一行的IPublishedContent尝试: IPublishedContent currentPage = Umbraco.TypedContent(CurrentPage.Id); 那么问题是x.IsVisible()不起作用所以你需要使用: x.GetPropertyValue
("isVisible") Umbraco.Content returns a dynamic. You need to get the IPublishe ... -
Umbraco 5:网站搜索(Umbraco 5: site search)[2022-10-17]
如你所知,Umbraco V5退役了; 您可以尝试4.x并使用umbraco节点工厂执行搜索逻辑的用户控件执行上述操作。 希望你能得到我的看法。 As you know Umbraco V5 is retire; you can try 4.x and do the above with user controls that do search logic using umbraco node factory. Hope you get my views. -
Umbraco使用Tempdata(Umbraco's useage of Tempdata)[2022-03-14]
这取决于你如何设置Umbraco的实例。 我刚刚使用Umbraco设置了一个负载均衡的网站,尽管已发布的网站负载均衡,但Umbraco后台却没有。 这主要是因为它不需要。 如果流量足够高,可以对应用程序进行负载平衡,但是对于Umbraco后台办公室来说,它可能不太可能有那么多的流量。 查看这篇文章 ,它解释了一些可用的选项。 我将已发布的站点设置为跨两个服务器进行负载均衡。 发布站点的两个实例都针对主域(www.site.com)进行解析,但每个实例都有一个唯一的非负载均衡子域(u1.site.com和u2 ... -
Umbraco 7 - Umbraco doc类型的只读属性[关闭](Umbraco 7 - Read Only property on Umbraco doc type [closed])[2022-12-27]
发现有一个标签数据类型,好像我错过了,傻我。 Found out there is a label data type, seems like I missed it, silly me. -
尝试清除您的Cookie,在升级之前,我大多只会看到类似这样的错误。 如果您清除cookie以记录自己,它应该清除错误。 Try clearing your cookies, I mostly only see errors like this when I am logged in before doing the upgrade. If you clear cookies to log yourself out it should clear the error.
-
Miniprofiler和umbraco(Miniprofiler and umbraco)[2023-04-27]
MiniProfiler内置于Umbraco v6和v7。 您不必手动设置它。 您所要做的就是通过在AppSettings中设置密钥来启用调试模式:并使用?umbDebug = true查询字符串参数加载页面。 MiniProfiler is built in to Umbraco v6 and v7. You don't have to manually setup it. All you have to do i ... -
我关掉了如何检索文件夹。 我挑出了原因,如果无论第二次合并命中,Umbraco是否尝试检索文件夹,如果它为空,则返回该错误,这是b / c 无法将类型'Umbraco.Core.Dynamics.DynamicNull'转换为'Umbraco.Web.Models.DynamicPublishedContent' 因此,您必须将实际的媒体ID(有效)传递给Umbraco.Media()方法,否则您将返回此错误。 public override ActionResult Index(RenderModel m ...
-
Umbraco 6与MVC 4(Umbraco 6 with MVC 4)[2022-06-13]
是的,只要您使用6.1+版本,我就可以用它来做你喜欢的事情。 这个umbraco页面可能会有所帮助,它具有覆盖 global.asax中自定义控制器的详细信息。 public class MyApplication : UmbracoApplication { protected override void OnApplicationStarting(object sender, EventArgs e) { DefaultRenderMvcControllerResolv ... -
在Umbraco的情况下。 我的应用程序是.Net FrameWork 4.0 umbraco以前的版本是使用.Net FrameWork 4.0,所以我试图在相同的FrameWork 4.0上使用Umbraco 7.0.1的新版本,在阅读一篇文章后,我检查了新版本的.Net Framework,发现是在.Net框架4.5,所以我升级我的应用程序到4.5它解决了这个问题。 感谢所有访问此帖的人。 In case of Umbraco. my application was on .Net FrameWork ...