Localization Not Formated

Feb 7, 2012 at 8:50 AM

While Localizing the ListItem Controls I am getting issue on build.

Considered the below code:

<src:ProductCategory>Books</src:ProductCategory

>   

 <src:ProductCategory>Computers</src:ProductCategory >

After i run the WPF addIn using static resource method , the modified content is as below

<src:ProductCategory><Static Member="lex:AddProductWindow.Books" xmlns="http://schemas.microsoft.com/winfx/2006/xaml" /></src:ProductCategory>

 

 

 

 

 

<src:ProductCategory><Static Member="lex:AddProductWindow.Computers" xmlns="http://schemas.microsoft.com/winfx/2006/xaml" /></src:ProductCategory>

while building i get the following error

The type 'ProductCategory' does not support direct content.

How to resolve these type of control content for localization....?

Coordinator
Feb 7, 2012 at 11:11 AM

How ProductCategory type is defined?

And please provide little more XAML to see how you put it inside ListItemControl.

Perhaps you'll need to adjust ProductCategory type definition in order to localize it using this approach.

E.g. perhaps use of xaml attribute instead of element content will help?

Feb 7, 2012 at 11:51 AM

ProductCategory is the enum class.. which i have defined,

add placeing the content for enum tag.

ok even though i used <ListItem> intead of ProductCategory..how i can use it.

Coordinator
Feb 7, 2012 at 1:28 PM

Ok, since it is enum, you must leave these values not localized (<src:ProductCategory>Computers</src:ProductCategory >). 

But when enum values are displayed by WPF, you can e.g. use custom template/converter to provide localization.

E.g. with ComboBox:

    <DataTemplate x:Key="EnumItemTemplate">

        <TextBlock Text="{Binding Converter={StaticResource EnumLocalizationConverter}}"/>

    </DataTemplate>

    <ComboBox ... ItemTemplate="{StaticResource EnumItemTemplate}">

Where EnumLocalizationConverter converts enum values to strings using resx files.