如何在wpf应用程序中使用.resx文件 [英] How to use .resx file in wpf application

查看:127
本文介绍了如何在wpf应用程序中使用.resx文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,

我是wpf应用程序的新手,想要使用标签内容属性来使用来自resources.resx的文本,这是wpf应用程序内部的属性,我正在寻找这样的解决方案,我可以在属性或整个应用程序中使用它,这样每当我创建任何窗口,我不需要在每个页面上添加这样的引用,



请尽快给我解决方案。



谢谢

解决方案

Hi.Do以下:

1-在解决方案资源管理器中打开属性,然后打开Resources.Resx

2-现在添加指定的图像。

3-将其访问修饰符从内部更改为公共。

4-现在在解决方案资源管理器中添加了一个名为资源的文件夹。

5-打开它并按F4查看图像的属性。然后将Build Action设置为Resources。

6-打开App.Xaml并编写以下XAML代码:

 <   Application.Resources  >  
< ResourceDictionary >
< BitmapImage x:键 = TestImage UriSource = / YourProjectNamespace; component / Resources / YourImageName.png / >
< / ResourceDictionary >
< / Application.Resources >



7-任何可以通过参考使用它的地方:

< Image Source ={StaticResource TestImage}/> 


Dear Sir,
I am new in wpf application and want to use the label content property to use for its text from resources.resx which is inside properties in wpf application , and i am looking for such solution which trough i can use this on property or in entire application so that whenever i create any window i don't need to add such reference on every page,

please provide me solution asap.

thanks

解决方案

Hi.Do following:
1- In the solution explorer open Properties and then open Resources.Resx
2- Now add your specified image.
3- Change its access modifier from internal into public.
4- Now in your Solution Explorer is added a folder that namd "Resources".
5- Open it and press F4 to see properties of your image. then set its Build Action to Resources.
6- Open App.Xaml and write following XAML code:

<Application.Resources>
        <ResourceDictionary>
            <BitmapImage x:Key="TestImage" UriSource="/YourProjectNamespace;component/Resources/YourImageName.png"/>
        </ResourceDictionary>
    </Application.Resources>


7- any where you can use it by referene it:

<Image Source="{StaticResource TestImage}"/>


这篇关于如何在wpf应用程序中使用.resx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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