WPF App.Xaml如何添加它 [英] WPF App.Xaml how to add it

查看:848
本文介绍了WPF App.Xaml如何添加它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我有一个问题也许它不符合逻辑但它确实发生在我身上。

我正在研究一个wpf应用程序,因为我确实删除了App.Xaml并添加了应用程序。 cs女巫包含主要方法。

和应用程序运行良好,但我需要添加一个资源字典,我确实发现它将在App.Xaml中添加,以便在所有使用它项目窗口,

但是现在我没有App.Xaml,我确实添加了一个manualy但它没有工作它不像生成的那个。

任何一个可以帮我添加一个而不创建项目??

Hi all i have a problem maybe it is not logical but it does happen with me.
I am working on a wpf application and for a reason i did remove App.Xaml and add app.cs witch contain main method.
and the application is working very well, but i need to add a resource dictionary and i did found that it will be add in App.Xaml in order to use it in all project window,
but now i don't have App.Xaml, i did Add one manualy but it was not working it is not like the generated one .
any one can help me to add one without creating the project ??

推荐答案

去添加新项目 - >在线模板,然后选择'Silverlight应用程序类'。

这将为您添加一个新的app.xaml。
Go to add new items -> online templates and then choose 'Silverlight Application Class'.
This will add a new app.xaml for you.


它无法正常工作的原因是因为当您删除App.xaml文件时,Visual Studio会将其作为项目属性中的Startup对象丢失。如果您已创建App.xaml文件(我在此处添加默认文件),则转到项目属性>申请>启动对象,然后在下拉列表中选择App.xaml文件。这是默认的XAML文件:
The reason that it is not working properly is because when you removed the App.xaml file, Visual Studio loses that as the Startup object in the project properties. If you have created the App.xaml file (I add a default one here), then you go to Project Properties > Application > Startup Object and you choose your App.xaml file in the drop down. Here's the default XAML file:
<Application

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

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

  StartupUri="[mainpage].xaml">
  <Application.Resources>
  </Application.Resources>
</Application>


也不要忘记:

设置对ApplicationDefinition的构建动作

(在App.xaml的属性中)
Also don't forget to:
set Build Action to ApplicationDefinition
(in properties of the App.xaml)


这篇关于WPF App.Xaml如何添加它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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