有时我们需要以编程方式在WPF中获取应用名称,即
icon.UriSource = new Uri("pack://application:,,,/AppName;component/Images/logo.ico");
我们怎么做?
谢谢!
答案 0 :(得分:4)
一种方法是:
icon.UriSource = new Uri(string.Format(
"pack://application:,,,/{0};component/Images/logo.ico",
Path.GetFileNameWithoutExtension(Application.ResourceAssembly.Location)));