2

I'm trying to add multiple languages to my WPF program. So I use Properties.Resources to store all visible strings.

In my XAML I have

<Window x:Class="DCMarker.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:loc="clr-namespace:DCMarker.Properties"
        Title="{x:Static loc:Resources.Title}" Height="534.6" Width="612" Loaded="Window_Loaded" Closed="Window_Closed"
        >
    <Grid>
        <Menu Height="26" VerticalAlignment="Top">
    <MenuItem Header="{x:Static loc:Resources.Tools}">
                    <MenuItem x:Name="ToolsConnect" Header="{x:Static loc:Resources.ToolsConnect}" Click="ToolsConnect_Click" />
                    <MenuItem x:Name="ToolsDisconnect" Header="{x:Static loc:Resources.ToolsDisconnect}" Click="ToolsDisconnect_Click" />
                    <Separator HorizontalAlignment="Left" />
                    <MenuItem x:Name="ToolsOptions" Header="{x:Static loc:Resources.ToolsOptions}" Click="ToolsOptions_Click" />
    </MenuItem>

But If I add a string to Resources this string will not be recognized by the XAML editor (or maybe Intellisence). Usually if I rebuild the solution they will be recognized but sometimes i have to restart VS2013.

Anyone have a clue why and how to fix this?

// anders

1 Answer 1

5

The StaticExtension class will only find public members and unfortunately when the code behind for the Resources.resx file is generated, the properties that retrieve the resources are marked internal.

To resolve this limitation you could go to your Resource' properties and change the “Custom Tool” from ResXFileCodeGenerator to PublicResXFileCodeGenerator, then compile your solution and try again.

1
  • I had changed the resources to public but the Custom Tool was set to ResXFileCodeGenerator... Fixed now! Thank you!!
    – Andis59
    Jan 27, 2015 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.