Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted
Updated 26-Jan-14 20:29pm
v2
Comments
Sergey Alexandrovich Kryukov 27-Jan-14 2:30am    
What have you tried so far?
—SA

1 solution

Create string resource item in your resx. The resx note in Visual Studio has a sub-node with auto-generated code. Open this file. You will find a static class member with the name identical or close to the name of your string resource. Use it immediately:
C#
System.Windows.Controls.Label myLabel = //... usually generated in your *.xaml.cs file; or create it by yourself in code

//...

myLabel.Text = Resource.MyResource.MyLabel; // find exact name from the file I mentioned above

The alternative is using XAML resources instead of resx. Unfortunately, it won't give you auto-generated code file, but then you would be able to use the resources in your XAML of your windows, pages or user controls. Please see:
http://msdn.microsoft.com/en-us/library/ms750613%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/aa348820%28v=vs.110%29.aspx[^],
http://blogs.msdn.com/b/wpfsldesigner/archive/2010/06/03/creating-and-consuming-resource-dictionaries-in-wpf-and-silverlight.aspx[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900