wpf & validation application block > message localization > messageTemplateResource Name&Type

Posted by Shaboboo on Stack Overflow See other posts from Stack Overflow or by Shaboboo
Published on 2010-04-28T15:00:38Z Indexed on 2010/04/28 15:03 UTC
Read the original article Hit count: 299

I'm trying to write validation rules for my data objects in a WPF application. I'm writing them in the configuration file, and so far they are working fine.

I'm stumped on how to localize the messages using messageTemplateResourceName and messageTemplateResourceType. What I know is that the strings can be writen in a resource file, given a name and referenced by that name. I get the idea, but i haven't been able to make this work.

<ruleset name="Rule Set">
    <properties>
        <property name="StringValue">
            <validator lowerBound="0" lowerBoundType="Ignore" upperBound="25"
          upperBoundType="Inclusive" negated="false" messageTemplate=""
          messageTemplateResourceName="msg1" messageTemplateResourceType="Resources"
          tag=""  
type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.StringLengthValidator, Microsoft.Practices.EnterpriseLibrary.Validation"
          name="String Length Validator" />
         </property>
    </properties>
</ruleset>

Where is the resource file and what value do I pass to messageTemplateResourceType? I have tried writing the messages in the shell project's resource file but no sucess trying to retrieve the value. I only get the default built-in message.

I've tried

  • messageTemplateResourceType="typeof(Resources)"
  • messageTemplateResourceType="Resources"
  • messageTemplateResourceType="Resources.resx"
  • messageTemplateResourceType="typeof(Shell)"
  • messageTemplateResourceType="Shell"
  • messageTemplateResourceType="Shell, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

I've also tried adding a new resource file in the shell project, and adding a resource file to the data object's library. I'm all out of ideas Does anyone have any suggestions? I'm not even married to the idea of resource files, so if there are other ways to localize these messages I'd love to know!

thanks

© Stack Overflow or respective owner

Related posts about wpf

Related posts about validation