【发布时间】:2016-07-31 06:48:32
【问题描述】:
您好,我一直在寻找 2 多个小时,但找不到合适的解决方案。我需要帮助如何在 XAML 中绑定 App.config 中的值(not 在 C# 中)。
这是一个带背景的网格,它有一个路径,但我想将它绑定到 App.config
<Grid x:Name="MainGrid">
<Grid.Background>
<ImageBrush ImageSource="{Binding Source=}" Stretch="UniformToFill"/>
</Grid.Background>
这是我的 App.config,因为我不知道哪个是正确的(在我的 wpf Book applicationSettings 中使用)我都发布了:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="bg_sun_key" value="../Assets/sun.png"/>
</appSettings>
<applicationSettings>
<MyAppName.Properties.Settings>
<setting name="bg_sun" serializeAs="String">
<value>../Assets/sun.png</value>
</setting>
<setting name="bg_planet" serializeAs="String">
<value>../Assets/planet.png</value>
</setting>
</MyAppName.Properties.Settings>
</applicationSettings>
</configuration>
我必须在 {Binding ...} 中写什么?还有其他建议吗?
我是 C# 和 UWP 的新手,所以请考虑一下。感谢您的帮助。
【问题讨论】:
标签: c# xaml win-universal-app