This is a migrated thread and some comments may be shown as answers.

DataField watermark text localization

5 Answers 145 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andrzej
Top achievements
Rank 1
Andrzej asked on 04 Apr 2014, 01:11 PM
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?

5 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 09 Apr 2014, 05:54 AM
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.

 
0
Daniil
Top achievements
Rank 1
answered on 08 Jun 2014, 08:40 PM
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>
0
Daniil
Top achievements
Rank 1
answered on 08 Jun 2014, 08:58 PM
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>
0
Rosy Topchiyska
Telerik team
answered on 11 Jun 2014, 08:45 AM
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.

 
0
Daniil
Top achievements
Rank 1
answered on 11 Jun 2014, 09:40 AM
Hello Rosy,

Thank you for answer, it resolves my problem.
Tags
DataForm
Asked by
Andrzej
Top achievements
Rank 1
Answers by
Todor
Telerik team
Daniil
Top achievements
Rank 1
Rosy Topchiyska
Telerik team
Share this question
or