Bug in RadTextBox

Thread is closed for posting
3 posts, 0 answers
  1. Vladimir
    Vladimir avatar
    15 posts
    Member since:
    Dec 2012

    Posted 20 Jan 2013 Link to this post

    Hi there,

    I found a bug in RadTextBox, namely
    if I clear the Text in RadTextBox by using the "X" clear button and then later assign the DataContext Property the RadTextBox does nothing... it still has an empty text inside.
    I've have a demo project:
    The Version of Telerik Controls: 2012.3.1211.3040
    Test Scenario:
    1. Open App.
    2. Tap button
    3. Clear text by using the "X" button.
    4. Tap Button again.
    5. Expected result: Text in RadTextBox
    6. Actual Result: Text is empty.

    As you can see the standart WP8 TextBox handles DataContext_Changed event and displays the text.

    I have,
    <StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">           
                <controls:RadTextBox Text="{Binding Text}" Height="100" Name="tnText"></controls:RadTextBox>
                <Button Click="ButtonBase_OnClick" Height="78">Set Data Context</Button>
                <TextBox Text="{Binding Text}" Height="72" TextWrapping="Wrap" />

    public class ViewModel : INotifyPropertyChanged
            private string _text;
            public string Text
                get { return _text; }
                    _text = value;
            public event PropertyChangedEventHandler PropertyChanged;
            protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
                PropertyChangedEventHandler handler = PropertyChanged;
                if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));

    and button click event:
    private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
                this.DataContext = new ViewModel
                    Text = "13222"

    best regards,
  2. Todor
    Todor avatar
    798 posts

    Posted 21 Jan 2013 Link to this post

    Hi Vladimir,

    Thank you for contacting us.

    The reason for this behavior is that when you press the clear button, the TextProperty is set to string.Empty and the binding is removed. The workaround is to set the binding to be two way:
    <controls:RadTextBox Text="{Binding Text, Mode=TwoWay}" Height="100" Name="tnText"></controls:RadTextBox>

    If this is not acceptable, please elaborate a bit more about your scenario and why would you need a one way binding to a property of a view model and also enable editing of the text box.

    All the best,
    the Telerik team
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  3. Vladimir
    Vladimir avatar
    15 posts
    Member since:
    Dec 2012

    Posted 21 Jan 2013 Link to this post

    Hi Todor ,

    Thank you for the responce. I'll try it later today. 

    best regards,
Back to Top