Reputation: 2246
[This is .Net 3.5.] I have seen a lot of examples that say, do it this way, so I must just be missing something:
I have a project with a Resources.resx file. In the Resources file are Strings that are Public. One of them is "Cancel", shown in this snippet from Resources.Designer.cs:
namespace WFT.PumpSvc.Bench.Properties {
public class Resources {
public static string Cancel {
get {
return ResourceManager.GetString("Cancel", resourceCulture);
}
}
...
Next, I have some xaml that has
xmlns:strings="clr-namespace:WFT.PumpSvc.Bench.Properties"
and
<wft:TouchButton Name="closeButton">"{x:Static strings:Resources.Cancel}"</wft:TouchButton>
(TouchButton inherits from Button.)
Instead of "Cancel" showing on my button, I see {x:Static strings:Resources.Cancel}. Is it obvious what I have missed that isn't finding the string?
Upvotes: 0
Views: 1713
Reputation: 185057
You made it a string, it won't be parsed like this, use element-syntax:
<wft:TouchButton Name="closeButton">
<x:Static Member="strings:Resources.Cancel"/>
</wft:TouchButton>
Upvotes: 2
Reputation: 292545
You can't write a markup extension directly in an element (at least not in this form), it must be in an attribute:
<wft:TouchButton Name="closeButton" Content="{x:Static strings:Resources.Cancel}"></wft:TouchButton>
You can also write it like this:
<wft:TouchButton Name="closeButton">
<x:Static Member="strings:Resources.Cancel" />
</wft:TouchButton>
Upvotes: 2