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

Datafield localization help

3 Answers 80 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.
Cocotteseb
Top achievements
Rank 1
Cocotteseb asked on 14 Dec 2015, 12:00 PM

Hi,

I am getting some trouble Datafield localization. I do not find my answer in the documentation. 

Following the documentation of DataForm, in "Defining Labels and Field Order", there is : "By default all editor fields are labeled by taking the name of the corresponding property on the source object. In most of the real-life scenarios you will need to change the labels with more friendly ones or event localize them. You can define custom labels by using the FieldInfo attribute as shown in the code snippet below"

However in C# I do not know how to localize as the string in the example is in plain text in a decorative field. 

Just below it is stated in paragraph Labels and XAML :"If you need to localize your labels you can define them in XAML. This is explained in the DataForm and XAMLs ection."

So in the documentation page "Using RadDataForm in XAML", I bet the concerned paragraph is at the bottom called "Defining Attributes for Data Fields in XAML
You can use the DataField.AttributeSet property to define property attributes for the property associated with a given DataField. For example, an alternative way to define the FieldInfo attribute is shown below"

However I cannot make the Binding working. I get an System.Windows.Markup.XamlParseException in System.Windows.ni.dll {"Object of type 'System.Windows.Data.Binding' cannot be converted to type 'System.String'."}

cf screenshots

Please, can you help me how to localize Datafield labels ?

 Thanks in advance !

 

 

3 Answers, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 17 Dec 2015, 12:45 PM
Hello,

Thank you for contacting us.

The attributes in RadDataForm inherit from the System.Attribute object which is not a DependencyObject so binding is not possible.
The extension point that we have exposed is the DataFieldCreating and DataFieldCreated events.

I hope this helps.

Regards,
Ivaylo Gergov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Cocotteseb
Top achievements
Rank 1
answered on 22 Dec 2015, 10:07 PM

Hi Ivaylo,

Thanks for your answer. I think it points me to the right direction. I'm though not 100% if I'm doing it right.  

For now I try to modify the label like this :

01.private void DataForm_DataFieldCreated(object sender, Telerik.Windows.Controls.DataFieldCreatedEventArgs e)
02. {
03.     switch (e.AssociatedField.PropertyKey)
04.     {
05.         case "ReleaseDate":
06.           ((Telerik.Windows.Controls.RadDatePicker)e.AssociatedField.Content).Header = "qwerty";
07.                 break;
08.         case "Name":
09.             e.AssociatedField.LabelContent = "qwerty2";
10.             break;           
11.     }
12. }

 Is it correct ? 

 

0
Ivaylo Gergov
Telerik team
answered on 28 Dec 2015, 08:01 AM
Hi,

Yes, this is the right approach.

Let me know should you need further assistance.

Regards,
Ivaylo Gergov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DataForm
Asked by
Cocotteseb
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Cocotteseb
Top achievements
Rank 1
Share this question
or