Cannot change DataField.Header from code

2 posts, 1 answers
  1. Ismael
    Ismael avatar
    3 posts
    Member since:
    Mar 2013

    Posted 30 Jan 2015 Link to this post

    I'm trying to dynamically update the Header of a DataField from code, but the UI won't update (other properties like Visibility do update the UI, though).

    Here's a simplified version of my code so far:

    <telerikInput:RadDataForm x:Name="radDataForm" DataFieldValueChanged="RadDataForm_OnDataFieldValueChanged">
        <telerikInput:DataField TargetProperty="Url" Header="Url (or IP)" />

    private void RadDataForm_OnDataFieldValueChanged(object sender, DataFieldValueChangedEventArgs e)
        var dataForm = sender as RadDataForm;
        if (dataForm == null)
        var urlField = dataForm.FindFieldByPropertyName("Url").AssociatedDataField;
        if (urlField != null)
            // NOTE: this won't update the UI
            urlField.Header = "IP (or Host) *";
            //// NOTE: this one DOES update the UI
            //urlField.Visibility = Visibility.Collapsed;

    Also, I've notice there is DataFile and DataFormField object: one has a Header and the other a LabelContent. Is there a way to work directly with the DataFormField in XAML?

  2. Answer
    Vladislav avatar
    275 posts

    Posted 03 Feb 2015 Link to this post

    Hi Ismael,

    It turns out that it is not possible to change directly the "Header" property of the DataField object.
    As a workaround you can change the LabelContent property of the DataFormField property, like this:
    var urlField = dataForm.FindFieldByPropertyName("Url");
    if (urlField != null)
        urlField.LabelContent = "IP (or Host) *";

    On your second question - since DataFormField is an object maintained internally by the RadDataForm it is not possible to work directly with it in XAML.

    Please note that we have discontinued the support for the WindowsPhone7 and we highly recommend to use our latest release of RadControls for WindowsPhone8.


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