DataField watermark text localization

6 posts, 0 answers
  1. Andrzej
    Andrzej avatar
    1 posts
    Member since:
    Feb 2013

    Posted 04 Apr 2014 Link to this post

    Hi,
    I've just installed trial of Windows Phone Controls. I'm trying to use localized string in watermark of DataField.
    Here is XAML from your template:

    <telerikInput:RadDataForm Grid.Row="1" Margin="12,48,12,0" x:Name="DataForm">
        <telerikInput:RadDataForm.CurrentItem>
            <models:SignInDataModel/>
        </telerikInput:RadDataForm.CurrentItem>
        <Grid>
            <telerikInput:DataField Header="" TargetProperty="UserName">
                <telerikInput:DataField.EditorStyles>
                    <Style TargetType="telerikPrimitives:RadTextBox">
                        <Setter Property="Watermark" Value="login"/>
                    </Style>
                </telerikInput:DataField.EditorStyles>
                <telerikInput:DataField.Validators>
                    <telerikInput:NonEmptyStringValidator/>
                </telerikInput:DataField.Validators>
            </telerikInput:DataField>
            <telerikInput:DataField Header="" TargetProperty="Password" telerikDataForm:PasswordField.IsPasswordField="True">
                <telerikInput:DataField.EditorStyles>
                    <Style TargetType="telerikPrimitives:RadPasswordBox">
                        <Setter Property="Watermark" Value="password"/>
                    </Style>
                </telerikInput:DataField.EditorStyles>
                <telerikInput:DataField.Validators>
                    <telerikInput:NonEmptyStringValidator/>
                </telerikInput:DataField.Validators>
            </telerikInput:DataField>
        </Grid>
    </telerikInput:RadDataForm>

    I'm trying to localize:
    <Setter Property="Watermark" Value="login"/>

    and
    <Setter Property="Watermark" Value="password"/>

    But when I'm trygin to do something like this:
    <Setter Property="Watermark" Value="{Binding Source={StaticResource LocalizedStrings}, Path=AppResources.Login}"/>

    I've got an exception:
    ArgumentException: Value does not fall within the expected range.

    I think it's because in XAML I can't use "Binding" in "Value" attribute of style setter in this place.
    What are best practices to localize watermarks in such places?
  2. Todor
    Admin
    Todor avatar
    778 posts

    Posted 09 Apr 2014 Link to this post

    Hello Andrzej,

    Thank you for your interest in RadDataForm.

    Your guess is right, you are not able to use binding in setters. The proper approach in this scenario would be to use RadTextBox as a custom editor. In your case that is:

    <telerikInput:DataField Header="" TargetProperty="UserName">
     
        <telerikInput:DataField.CustomEditor>
            <telerikDataForm:CustomEditor>
                <telerikPrimitives:RadTextBox
                            Watermark="{Binding Source={StaticResource LocalizedStrings}, Path=AppResources.Login}" telerikDataForm:CustomDataField.IsEditor="True" telerikDataForm:CustomDataField.EditorValuePath="Text" />
                </telerikDataForm:CustomEditor>
            </telerikInput:DataField.CustomEditor>
     
        <telerikInput:DataField.Validators>
            <telerikInput:NonEmptyStringValidator/>
        </telerikInput:DataField.Validators>
     
    </telerikInput:DataField>

    I hope this information helps. Let us know if you need further assistance.

    Regards,
    Todor
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
  4. Daniil
    Daniil avatar
    3 posts
    Member since:
    May 2014

    Posted 08 Jun 2014 in reply to Todor Link to this post

    Hello Todor,

    I've used RadTextBox with CustomEditor and get an exception while property dataForm:CustomDataField.IsEditor equals "True" in the following context:

    <
    telerikInput:RadDataForm Grid.Row="0" Margin="12,48,12,0" x:Name="SignInDataForm">
        <telerikInput:RadDataForm.CurrentItem>
            <models:SignInDataModel/>
        </telerikInput:RadDataForm.CurrentItem>
        <Grid>
            <telerikInput:DataField Header="" TargetProperty="Email" >
                <telerikInput:DataField.CustomEditor>
                    <dataForm:CustomEditor>
                        <telerikPrimitives:RadTextBox Watermark="{Binding Path=LocalizedResources.EmailAddress, Source={StaticResource LocalizedStrings}}" Style="{StaticResource TextBoxMulticolorStyle}"
                                                      InputScope="EmailNameOrAddress" dataForm:CustomDataField.EditorValuePath="Text" />
                    </dataForm:CustomEditor>
                </telerikInput:DataField.CustomEditor>
                <telerikInput:DataField.Validators>
                    <telerikInput:NonEmptyStringValidator/>
                    <telerikInput:EmailValidator/>
                </telerikInput:DataField.Validators>
            </telerikInput:DataField>
            <telerikInput:DataField Header="" TargetProperty="Password" dataForm:PasswordField.IsPasswordField="True">
                <telerikInput:DataField.CustomEditor>
                    <dataForm:CustomEditor>
                        <telerikPrimitives:RadPasswordBox Watermark="{Binding Path=LocalizedResources.Password, Source={StaticResource LocalizedStrings}}" Style="{StaticResource MulticolorRadPasswordBoxStyle}"
                                                          dataForm:CustomDataField.IsEditor="True" dataForm:CustomDataField.EditorValuePath="Password" />
                    </dataForm:CustomEditor>
                </telerikInput:DataField.CustomEditor>
                <telerikInput:DataField.Validators>
                    <telerikInput:NonEmptyStringValidator/>
                    <helpers:MinLengthValidator/>
                </telerikInput:DataField.Validators>
            </telerikInput:DataField>
        </Grid>
    </telerikInput:RadDataForm>
  5. Daniil
    Daniil avatar
    3 posts
    Member since:
    May 2014

    Posted 08 Jun 2014 in reply to Daniil Link to this post

    ArgumentException: Value does not fall within the expected range.

     is suited in the case of

    <telerikInput:DataField.CustomEditor>
        <dataForm:CustomEditor>
            <telerikPrimitives:RadTextBox Watermark="{Binding Path=LocalizedResources.EmailAddress, Source={StaticResource LocalizedStrings}}" Style="{StaticResource TextBoxMulticolorStyle}"
                                          InputScope="EmailNameOrAddress" dataForm:CustomDataField.IsEditor="True" dataForm:CustomDataField.EditorValuePath="Text" />
        </dataForm:CustomEditor>
    </telerikInput:DataField.CustomEditor>
  6. Rosy Topchiyska
    Admin
    Rosy Topchiyska avatar
    550 posts

    Posted 11 Jun 2014 Link to this post

    Hello Daniil,

    Thank you for writing.

    The RadTextBox and RadPasswordBox do not support null values. If you initialize the properties of your business object with string.Empty, you should not get this exception.

    I hope this helps. Please, let us know if you have further questions.

    Regards,
    Rosy Topchiyska
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Daniil
    Daniil avatar
    3 posts
    Member since:
    May 2014

    Posted 11 Jun 2014 in reply to Rosy Topchiyska Link to this post

    Hello Rosy,

    Thank you for answer, it resolves my problem.
Back to Top
DevCraft banner