Datafield localization help

4 posts, 0 answers
  1. Cocotteseb
    Cocotteseb avatar
    6 posts
    Member since:
    Apr 2008

    Posted 14 Dec 2015 Link to this post

    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 !

     

     

  2. Ivaylo Gergov
    Admin
    Ivaylo Gergov avatar
    661 posts

    Posted 17 Dec 2015 Link to this post

    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
  3. DevCraft banner
  4. Cocotteseb
    Cocotteseb avatar
    6 posts
    Member since:
    Apr 2008

    Posted 22 Dec 2015 in reply to Ivaylo Gergov Link to this post

    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 ? 

     

  5. Ivaylo Gergov
    Admin
    Ivaylo Gergov avatar
    661 posts

    Posted 28 Dec 2015 Link to this post

    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
Back to Top
DevCraft banner