Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How do I localize XAML TextBlocks?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Infralution Support Forum Index -> Globalizer FAQ
View previous topic :: View next topic  
Author Message
Infralution



Joined: 28 Feb 2005
Posts: 4855

PostPosted: Wed Aug 18, 2010 1:06 am    Post subject: How do I localize XAML TextBlocks? Reply with quote

Say you have an XAML TextBlock like:

Code:
<TextBlock>Some Text</TextBlock>


When you scan the XAML with Globalizer the content of the text block is not picked up. If you look at the default WPF Options (when scanning) you will see there is no specific entry for TextBlocks. If you try to add a WPF Conversion rule for "TextBlock.Content" then the TextBlock content will be scanned - but you now have another problem. Globalizer will convert the element to something like:

Code:
<TextBlock>
   <Resx ResxName="MyApp.Window1" Key="TextBlock_Content1" />
</TextBlock


And when you try to open this in the designer you will get the following error:

Quote:
The property 'Inlines' is read-only and cannot be changed.


The problem is that the TextBlock element does not support any child elements other than simple text - so you cannot localize the content like this. So instead of adding a conversion rule in Globalizer for "TextBlock.Content" you need to change your XAML to set the Text property (inside the TextBlock tag) like:

Code:
<TextBlock Text="Some Text" ></TextBlock>


The default Globalizer WPF conversion rules (which scan the Text properties of all controls) will now scan and convert the element to something like:

Code:
<TextBlock Text="{Resx ResxName=MyApp.Window1, Key=TextBlock_Text1}"  ></TextBlock>


This will now load as expected in the designer.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Infralution Support Forum Index -> Globalizer FAQ All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group