Updating TextBox from ViewModel

13 posts, 0 answers
  1. Peter
    Peter avatar
    2 posts
    Member since:
    Jun 2012

    Posted 18 Jun 2012 Link to this post

    Hi,

    When setting the text of a TextBox by modifying the variable it is bound to, both the text and the watermark are showing.

    Set-up: Text field of a TextBox databound (two-way) to a variable on a ViewModel
    Action: Changing the variable on the ViewModel updates the Text property on-screen accordingly
    Problem: The watermark does not disappear until the TextBox gets focus by tapping on it

    Bug or feature :-) ?
  2. Vijay
    Vijay avatar
    29 posts
    Member since:
    Nov 2011

    Posted 19 Jun 2012 Link to this post

    Hello Peter,

       This may be caused because you might have specified an additional watermark property with some holding text. Please find the below sample code, where the watermark property is included. If you don't actually specify this property this will not show up in RadTextBox.

    <primitives:RadTextBox ActionButtonVisibility="Visible" Watermark="Enter FirstName Here" Header=”Please Enter FirstName”/>


    Thanks and Regards,
    Vijay
    MVC Corp
  3. DevCraft banner
  4. Todor
    Admin
    Todor avatar
    778 posts

    Posted 19 Jun 2012 Link to this post

    Hi Peter,

    I tried to reproduce the issue described but couldn't. I have added a sample application to illustrate how RadTextBox works perfectly when bound to property from a ViewModel and the watermark disappears when the text is changed just as expected.

    Let me know, if there is anything else more specific in your scenario.

    Regards,
    Todor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Peter
    Peter avatar
    2 posts
    Member since:
    Jun 2012

    Posted 19 Jun 2012 Link to this post

    Hi Vijay,

    Based on your feedback I dug a little deeper and narrowed it down to this:

    - I have two views working on the same viewmodel
    - view 1 has a couple of controls databound to variables on the viewmodel 
    - one of those is a textbox 
    - the controls can be prefilled by going to a second view where the user can pick some entity from a list
    - based on the selection view 2 updates the viewmodel and navigates back to view 1
    - when view 1 is displayed, both the watermark and the text are showing

    I've put the above logic in a small sample showing the issue but am unable to attach the zip file to this post... 

    Thanks,

    Peter
  6. Vijay
    Vijay avatar
    29 posts
    Member since:
    Nov 2011

    Posted 19 Jun 2012 Link to this post

    Hello Peter,


       As known, .zip extension files or .zwf extension files cannot be attached to forums for some security concerns. If you wish to send the source code you may raise support ticket where the telerik team can look into your request. Either way to send your implementation logic would be, you can add code block in forums section or send us some images where scenario can be understood clearly.

    Please don't hesitate to connect us, for any further clarifications. 

    Thanks and Regards,
    Vijay
    MVC Corp.
  7. Pierre Huguet
    Pierre Huguet avatar
    6 posts
    Member since:
    Dec 2008

    Posted 20 Jun 2012 Link to this post

    I have the Same Problem the watermark stays on top of a databound TextBox
    Until the textbox gets edited.
  8. Todor
    Admin
    Todor avatar
    778 posts

    Posted 22 Jun 2012 Link to this post

    Hi,

    We still can't reproduce the issue that you are describing even when following you scenario. As Vijay explained, you should open a new support ticket in order to be able to attach a project and send it to us. This would help us a lot as we will be able to debug it and find exactly what is causing the undesired behavior.

    Thank you for your time.

    All the best,
    Todor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  9. Ingrid
    Ingrid avatar
    4 posts
    Member since:
    Dec 2011

    Posted 22 Jun 2012 Link to this post

    Hi, 

    I just filed a bug related to this topic using our company account and attached a screenshot and zip file.
    Have been out for a couple of days, sorry for the delay...

    Peter
  10. Todor
    Admin
    Todor avatar
    778 posts

    Posted 22 Jun 2012 Link to this post

    Hi Johan,

    Thank you for the provided application. We will see what is causing the issue and will let you know when the fix is ready.

    Thank you for your time.

    All the best,
    Todor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  11. Mikael
    Mikael avatar
    4 posts
    Member since:
    May 2011

    Posted 08 Jul 2012 Link to this post

    You can reproduce the error with a small modification to the example provided by Todor. Just set the initial text in the constructor of the ViewModel:

            public MainViewModel()
            {
                 this.TextBoxValue = "Initial value";
            }

  12. Mikael
    Mikael avatar
    4 posts
    Member since:
    May 2011

    Posted 09 Jul 2012 Link to this post

    Ok, this is a stupid hack but seems to get around the problem. Instead of setting the value directly in the view model's constructor, use ThreadPool.QueueUserWorkItem to delay the operation. For example:

            public MainViewModel()
            {
                ThreadPool.QueueUserWorkItem(x =>
                                                 {
    Thread.Sleep(300);


    this.TextBoxValue = "Initial value";
                                                 });
            }

    If you're not using Caliburn.Micro, make sure to use Dispatcher to set the value.
  13. Todor
    Admin
    Todor avatar
    778 posts

    Posted 09 Jul 2012 Link to this post

    Hello Michael,

    Thank you for sharing your workaround.

    We have resolved this issue and you will be able to get the fix with our next internal build that will be released later this week.

    Kind regards,
    Todor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  14. Todor
    Admin
    Todor avatar
    778 posts

    Posted 11 Jul 2012 Link to this post

    Hi,

    I am happy to inform you that you can now download our latest internal build from the downloads section of your accounts. You should no longer see both watermark and text in the same time in RadTextBox.

    Greetings,
    Todor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner