2011-08-10 60 views
3

C#,Visual Studio 2010中,Windows 7的C#,属性使用字符串

当您设置图像WPF控件图像可以specifify源的图像这样

/MyTest;component/images/Misc/bg.jpg 

但你如何用字符串做,我有一些字符串资源,例如, strings.resx,strings.sv-Se.resx等等,并且当 指定文本到一个按钮时,要使用这个“字符串概念”。

我应该在属性(或窗口的XAML文件)中编写回收字符串?

我已经试过

/MyTest;component/strings.File 

我:​​

但似乎没有任何工作。

+0

取决于你想要达到(本地化?),[这](HTTP什么://计算器.com/questions/665764/how-to-fetch-string-from-resource-to-assign-in -wpf-resource-section-in-xaml)也许你在找什么或者这个问题甚至是重复的。 –

回答

2

设置的resx文件的访问说明符是public

<Window x:Class="WpfApplication1.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:prop="clr-namespace:WpfApplication1.Properties" 
     Title="MainWindow" Height="350" Width="525"> 
    <Grid> 
     <TextBox Text="{x:Static prop:Resources.String1}"/> 


    </Grid> 
</Window> 

refrence:访问字符串从resx file

+0

嗨 非常感谢,这做的伎俩,您的建议也导致我到这个网站 http://gargmanoj.wordpress.com/2009/03/18/accessing-strings-from-resource-file-in -xaml-markup/ Regards –