Hi,
I would like to do the following, what is the best way to accomplish this? Can I do this with CodeRush/Refactor Pro! or do I need to make a VS add-in? This is similar to Microsoft's Resource Refactoring Tool, but this is for XAML. This makes it easy for localization. This is what I would like to do (I am tired of doing this manually!):
1. When I am in Xaml, I would like to type in a string, and then be able to move it to a string resource file. For example:
<Label Content="First Name" />
I would like to highlight First Name, and perhaps have it popup a list of resource dictionary xaml files, and I can choose one, and it will put this in there:
<system:String x:Uid="Words_FirstName" x:Key="Words_FirstName">First Name</system:String>
(note, that there is a Words_ prefix, corresponds to the name of the file, Words.xaml)
and then it will change the original label to:
<Label Content="{StaticResource Words_FirstName}" />
(this works since I have the Words.xaml resource dictionary in the Application MergedDictionaries Resource)
Also, I have a code behind file in the ResourceDictionary, so I can also have it strongly typed to access it via code:
public static string FirstName { get { return GetStringResource("FirstName"); } }
(this calls GetStringResource which takes care of having a static Resource Dictionary variable to the appropriate dictionary. I will not include the code here for brevity sakes)
2. I would also like to be able to do this in code, for example,
MessageBox.Show("There was an error");
I would like to be able to do step #1 above (where it makes Xaml ResourceDictionary entry and then makes the strongly typed static property in the code behind file), and then it changes the above code to:
MessageBox.Show(ErrorMessages.ThereWasAnError);