问题标签 [app.xaml]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
52364 浏览

c# - 在代码中设置静态资源

我的App.xaml文件中有一些样式:

我想更改BackgroundProperty我的mainpage.xaml.cs.

我尝试使用这个:

但我得到一个灾难性的失败异常。我认为这与{StaticResource styleRed}. 有一个更好的方法吗?

0 投票
1 回答
1102 浏览

c# - Why do I not have access to App.xaml.cs from other classes in my app?

I'm trying to declare a global var in App.xaml.cs this way:

I added a "Loaded" event to the map in MainPage.xaml.cs:

...which event gets the Session Key, assigning it to the global var:

However, when I try to access that value when making a REST call:

...I get a red "SessionKey" and on the dot between "App" and "SessionKey" it says, "Invalid expression term '.'"

-and: "; expected" in the same place, and "Invalid expression term ')'" on the ")" at the end of the call to String.Format().

Why is "App" unrecognized? The class where these errors occur is in the same namespace. Why wouldn't it see the application instance?

0 投票
1 回答
7104 浏览

wpf - App.xaml 中的合并字典

我在一个单独的.xaml. 我window使用以下指令将它们加载到我的内部:

我有很多窗口,所以我想简单地将这段代码放在App.xaml.

我正在尝试这个:

所以这里是问题:

所有示例都没有使用x:Key属性,但它给了我一个错误,说我需要。当我这样做时,它说我不能拥有多个属性Resource......

0 投票
2 回答
440 浏览

c#-4.0 - 在 Windows Phone 8.1 上共享文件

可以有人帮助我编写我自己的通用 Windows 商店应用程序我希望我的 xaml 页面选择一个文件,然后使用 windows phone 8.1 上的共享合同共享它。问题是我的 windows phone 8.1 应用程序,当我选择一个文件时它会遇到断点并且无法识别这行代码 IReadOnlyList pickFiles = await filePicker.PickMultipleFilesAsync()。这适用于 Windows 8.1 版本而不是 Windows Phone 8.1 版本。

0 投票
1 回答
2111 浏览

wpf - WPF c# app.xaml 意外删除

我正在开发一个 wpf 应用程序,出于某种原因,我确实删除了 App.Xaml 并添加了 app.cs 女巫包含 main 方法。并且应用程序运行良好,但我需要添加一个资源字典,我确实发现它将添加到 App.Xaml 中以便在所有项目窗口中使用它,但现在我没有 App.Xaml,我确实手动添加了一个,但它不起作用,它不像生成的那样。任何人都可以帮助我添加一个而不创建新项目?

0 投票
1 回答
453 浏览

c# - Mahapps Metro theme not appearing if using App_Startup in App.xaml

Have had Mahapps working for a while in this project in all windows, but as soon as I changed in apps.xaml

the theme is no longer there.

The program still works normally, does everything I need it to other than display the theme.

here is the App_Startup that I'm using to open the windows that don't have the themes.

Is there something I should change or add to help the theme start?

Edit: I'm assuming it has something to do with the Resource Dictionary that is in the App.xaml, those are all there but not loaded with the above code somehow?

0 投票
1 回答
72 浏览

testing - 如何在 Windows Phone 8.1 中获取 Page 的 x:Class 属性?

我有一个应用程序。我想得到一个页面的 x:class 来区分页面。如何获取 App6.MainPage ?

我正在尝试这个我有 ListControl 功能: private void ListControl() { Frame currentFrame = null; 尝试 { currentFrame = Window.Current.Content as Frame;

和 ClearListControl 函数

. 最后,我得到属性页面:

请帮我。感谢您的帮助!

0 投票
2 回答
950 浏览

windows-store-apps - 如何使用 OK 和 Cancel 按钮创建 toast 通知?

有没有办法用按钮创建一个 toast 通知,然后处理按钮的点击事件?

谢谢

0 投票
1 回答
109 浏览

xaml - 如何在空的 App.xaml 中消除这些莫名其妙的设计时错误?

App.xaml在 Silverlight 5 应用程序项目中遇到问题。基本上,我可以从中删除所有内容(里面的资源<Application.Resources>,例如样式和转换器),直到我只剩下这个:

但 Visual Studio 2013 的错误列表窗口仍将列出以下三个(可忽略的)设计时错误:

  • “资源”属性只能设置一次。(App.xaml,第 1 行,第 1 列)
  • “Key”属性只能用于“IDictionary”中包含的元素。(App.xaml,第 1 行,第 1 列)
  • 无法分配指定的值。预期以下类型:“ResourceDictionary”。(App.xaml,第 1 行,第 1 列)

这些纯粹是设计时错误;我可以成功编译并运行该项目。但是,这些错误没有任何意义,而且很烦人。

有谁知道如何摆脱它们?

我已经尝试过的一些事情:

  • 清理和重建整个解决方案。
  • 手动擦除工件目录App.g.i.*中的文件。obj
  • 手动删除objbin目录。
  • 我确保它App.xaml在主 Silverlight 应用程序项目中(而不是在其他一些类库中);并且没有其他类型为“ApplicationDefinition”的项目项。
0 投票
1 回答
693 浏览

c# - 在“ResourceDictionary”类型中找不到可附加属性“ThemeDictionaries”

以下代码位于 Windows Phone 8 应用程序的 app.xaml 中。它收到错误The attachable property "ThemeDictionaries" was not found in type "ResourceDictionary"。同样,它不设置背景。(App.Current.Resources["BackgroundImage"] as ImageBrush).ImageSource = imgSrc; 我正在尝试使用通过 c# 代码更改它的选项来设置整个应用程序的背景。