首页 \ 问答 \ Hello World [WPF](Hello World [WPF])

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
更新时间:2023-02-06 17:02

最满意答案

我关掉了如何检索文件夹。 我挑出了原因,如果无论第二次合并命中,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 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的实例。 我刚刚使用Umbraco设置了一个负载均衡的网站,尽管已发布的网站负载均衡,但Umbraco后台却没有。 这主要是因为它不需要。 如果流量足够高,可以对应用程序进行负载平衡,但是对于Umbraco后台办公室来说,它可能不太可能有那么多的流量。 查看这篇文章 ,它解释了一些可用的选项。 我将已发布的站点设置为跨两个服务器进行负载均衡。 发布站点的两个实例都针对主域(www.site.com)进行解析,但每个实例都有一个唯一的非负载均衡子域(u1.site.com和u2 ...
  • 发现有一个标签数据类型,好像我错过了,傻我。 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 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 ...
  • 是的,只要您使用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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)