in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

Advice on extracting strings into Xaml Resource Dictionary

Last post 10/11/2007 4:35 AM by Rory Becker [DX-Squad]. 5 replies.
Page 1 of 1 (6 items)
Sort Posts:
Previous Next
  • 9/12/2007 12:55 PM

    Advice on extracting strings into Xaml Resource Dictionary

    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);

     

     

    Filed under: ,
  • 9/24/2007 12:33 PM In reply to

    Re: Advice on extracting strings into Xaml Resource Dictionary

    Hi Daniel,
     
    Please accept our apologies for the delay in responding. This looks like a good suggestion and there's a great chance that we'll implement this in future. I've added this issue to the Support Center. You're welcome to track its status here:
     
    R&D, IDE Team Developer Express Inc.
     
    PS. If you wish to receive direct assistance from our Support Team, use
    Support Center at http://www.devexpress.com/Support/Center
    Please take a look at our Knowledge Base at: http://www.devexpress.com/kb.
    It contains useful information on our products that may save time.
  • 10/9/2007 12:29 PM In reply to

    Re: Advice on extracting strings into Xaml Resource Dictionary

    OK thanks, but can you tell me how I can also update a code behind file if I am adding something to Xaml?  Because, even if you add this feature, I will probably want to customize it.

    Thanks,

     Dan


     

  • 10/10/2007 9:05 AM In reply to

    Re: Advice on extracting strings into Xaml Resource Dictionary

    Hi Dan,
     
    You can use TextBuffers for changing any project files (see CodeRush.TextBuffers.XXX). If you need help with this let me know.

    --
    Thanks, Alex S
     
    R&D, IDE Team Developer Express Inc.
     
    PS. If you wish to receive direct assistance from our Support Team, use
    Support Center at http://www.devexpress.com/Support/Center
    Please take a look at our Knowledge Base at: http://www.devexpress.com/kb.
    It contains useful information on our products that may save time.
  • 10/11/2007 1:20 AM In reply to

    Re: Advice on extracting strings into Xaml Resource Dictionary

    Hi Alex,

    So I can't just do it in a template, I need to do something else?  I have not done this before, is there a tutorial or document on how to get up to speed quickly on this?

     Thanks,
     

    Dan 

  • 10/11/2007 4:35 AM In reply to

    Re: Advice on extracting strings into Xaml Resource Dictionary

    > So I can't just do it in a template, I need to do something else? I
    > have not done this before, is there a tutorial or document on how to
    > get up to speed quickly on this?

    If I'm not mistaken, DevExpress will be adding this (when they do) as a DXCore
    plugin.

    The DXCore is the framework on which RefactorPro and Coderush are built.

    It is also possible for you to build your own plugins. I have some examples
    over at http://www.rorybecker.me.uk/.

    There is even a dedicated forum for the DXCore http://community.devexpress.com/forums/181.aspx

    What you are looking to do will, I think, require such a plugin.

    Which options DevExpress will add to such a plugin? or whether they will
    release the source to it? are different questions.
    Rory Becker - DX-Squad
    Blog, DXCore Community Plugins
    (Follow me @ http://twitter.com/RoryBecker)
Page 1 of 1 (6 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED