Change TextBox value in the property setter RRS feed

  • General discussion

  • Exactly the same problem like: 

    Sliverlight Change TextBox value in the property setter

    but a solution with a converter doesn't/can't work ...

    If you implement it in the code-behind file with TextChanged event it works, but this isn't satisfying solution for me ...


            <TextBox HorizontalAlignment="Stretch" 
                     Text="{Binding Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>

        public class ViewModel : INotifyPropertyChanged
            private string _text;
            public string Text
                    return _text;
                    _text = "You will not see this text.";
            public event PropertyChangedEventHandler PropertyChanged;
            protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
                var eventHandler = this.PropertyChanged;
                if (eventHandler != null)
                    eventHandler(this, new PropertyChangedEventArgs(propertyName));
    This code works in a Windows Application .Net 4.5 but doesn't in a Windows Store app, and I don't see a reason why ...

    • Edited by diego2k Sunday, July 20, 2014 5:51 PM
    Sunday, July 20, 2014 4:40 PM

All replies

  • You want to completely change the value of property that you have bound to something else regardless of what user types, this requirement does not look like practical. Can you explain the actual use case that you want to implement? 

    -- Vishal Kaushik --

    Please 'Mark as Answer' if my post answers your question and 'Vote as Helpful' if it helps you. Happy Coding!!!

    • Edited by Vishal Kaushik Monday, July 21, 2014 7:54 PM I think i started responding before @diego2k edited to add code :)
    Sunday, July 20, 2014 4:49 PM
  • I have used the codebehind solution for now -.- 

    but I think it's still a problem in WinRT/WPF ...

    Wednesday, August 13, 2014 10:51 AM
  • i maked my own control that extends from TextBox. THen i added a new text dp and use text changed there. so you have a reuseable solution.

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, August 13, 2014 10:59 AM