【发布时间】:2017-05-06 21:43:57
【问题描述】:
好吧,我想构建一个多语言系统,但是在图像源中加载字典值时遇到了一些问题。当我将变量绑定到文本框时,它会完美地显示该值,但同样不适用于图像源,这是我的代码:
Dictionary<string, string> resource = new Dictionary<string, string>()
{
{ "play_ready", "Resources/" + Config.Language + "play_ready.png" },
{ "play_click", "Resources/" + Config.Language + "play_click.png" },
{ "background", "Resources/" + Config.Language + "background.png" },
{ "exit", "Resources/" + Config.Language + "exit.png" },
{ "exit_click", "Resources/" + Config.Language + "exit_click.png" },
{ "exit_hover", "../../../Resources/exit_hover.png" }
};
public Dictionary<string, string> resourcesPath { get; set; }
public MainWindow()
{
InitializeComponent();
DataContext = this;
resourcesPath = resource;
Config.Setup(this.configUrl);
this.client = new Client();
}
我在 XAML 中有这个
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="border">
<Setter.Value>
<ImageBrush ImageSource="{Binding resourcesPath[exit_hover]}"/>
</Setter.Value>
【问题讨论】:
标签: c# wpf xaml dictionary