none
No UpdateSourceTrigger?

    Question

  • It looks like WinRT's Binding (in the Windows.UI.Xaml.Data namespace) doesn't have the UpdateSourceTrigger property.

    Is there any way to get a TextBox to push its updates into the target on each keypress rather than having to wait for a loss of focus?

    It doesn't even look like we can retrieve the binding expression and give it a poke by hand, because there's no GetBindingExpression helper to get hold of the binding, and even if there were, the binding doesn't have an UpdateSource method.

    Try running the Data Binding sample from the Metro SDK samples, and for Scenario 1, go to the 2nd TextBox (the one with the TwoWay mode), edit the number, hit the Return key. I can cope with it not updating with every singel keypress in this case (although there are scenarios where you really do want that, particularly around doing a good job with validation of input)

    But the fact that it doesn't even pick up the change when you hit Enter - doesn't it just feel broken?

    Wednesday, September 28, 2011 4:06 PM

Answers

  • Ian, your feedback on UpdateSourceTrigger is acknowledged and has been passed onto the appropriate feature crew on our team. Much appreciated!
    Ashish Shetty, Program Manager, Microsoft | http://nerddawg.blogspot.com
    • Marked as answer by IanGMVP Friday, September 30, 2011 9:25 PM
    Friday, September 30, 2011 7:24 PM

All replies

  • Ian - can you please forward this feedback at our Connect site?
    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    Thursday, September 29, 2011 5:01 PM
    Moderator
  • Sure. What product should I file that under? I just searched for "Metro", "WinRT", and "Windows 8" in the Product Directory on connect, and got back nothing for all of them. I don't see anything relevant under https://connect.microsoft.com/directory/windows/ or https://connect.microsoft.com/directory/developer-tools/

    What's the proper place to file feedback for WinRT XAML development?


    [update] I typed in the code I got for connect on the piece of card in the build attendee pack. But that only appears to let me into WERP (Windows Ecosystem Readiness Program). Its "submit feedback" feature only accepts bug report, not feature requests. (This seems like a feature request.) And it says:

    "You should only need this form for setup failures."

    And it wants me to attach a bunch of log files that I'm pretty sure are related to setup and installation. So that seems like very much the wrong place to send this feedback

    • Edited by IanGMVP Thursday, September 29, 2011 11:00 PM
    Thursday, September 29, 2011 10:39 PM
  • Here's the exact form I am given to send out:

    Thank you for posting your feedback, we want to make sure we get the right info including your log files.  Can you also submit feedback using the Windows Feedback Tool from the Connect Site associated with your Windows Developer Preview program? If you’re an MSDN subscriber, the information on how to join the Connect program is included on the download page where you installed Windows Developer Preview.  There’s a link to the Connect site and an invitation code that you can click on to join using a Windows Live ID account. If you’re not an MSDN subscriber follow this limited use link to join the Connect program and then follow the steps here

    If this does not work, pleaes email me msmall at microsoft and let me know - we'll get the right info to you.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    Friday, September 30, 2011 4:14 PM
    Moderator
  • "the information on how to join the Connect program is included on the download page where you installed Windows Developer Preview." - hmm. The preview came pre-installed on the tablet I received as //build/ conference attendee. So the preview was installed by Microsoft before they provided the tablet. I presume it was downloaded from Microsoft's internal networks...

    The downloads are available from http://msdn.microsoft.com/en-us/windows/apps/br229516.aspx and there's no information on the connect program there that I can see.

    I have an MSDN sub. I see the "Windows Developer Preview" section in the Subscriber downloads section, and again, I see no information about Connect when I expand any of the "Details" sections for the various downloads there.

    But in any case, I don't think any of this actually helps, because the issue I've raised here isn't a bug. It's a feature request. The steps described in that final link seem to be about reporting bugs (which I can already do). I think you've pointed me to instructions for doing the thing that I've already said is not what I need to do. I'm not attempting to report a bug. For connect purposes, this would be a feature request. (Although it's really just a question - I was hoping for some clarification from someone on the relevant team about this.)

    The log files won't be of any use to you because the issue I'm raising here is an API design issue. In fact, the problem I've described can be seen without even needing to install the Windows Developer Preview. All the information required to discover the problem can be found just by reading the documentation up at the Metro developer centre, specifically the documentation up at http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.data.binding(v=VS.85).aspx As it happens, I was using my main Windows 7 desktop to browse that site when I discovered the problem so the log files from my Win8 device really aren't going to help you.

    (I did then try this out on my Windows 8 system. The system behaved exactly as the documentation said it should, so I can't reasonably call it a bug. It's a design shortcoming.)

    I'm afraid the canned response you've been given isn't relevant to the issue I'm describing. (Also, as described above, it appears to contain incorrect information for the scenario that it's actually intended for, so you might need to take that form back to whoever gave it to you. But even when fixed, it's not the right thing for this scenario.)

    But if the only path for getting this information where it needs to be is to submit it as a 'bug' even though it's not, I can do that. Is that what I should do?

     

    Friday, September 30, 2011 6:33 PM
  • Ian, your feedback on UpdateSourceTrigger is acknowledged and has been passed onto the appropriate feature crew on our team. Much appreciated!
    Ashish Shetty, Program Manager, Microsoft | http://nerddawg.blogspot.com
    • Marked as answer by IanGMVP Friday, September 30, 2011 9:25 PM
    Friday, September 30, 2011 7:24 PM
  • Thanks!
    Friday, September 30, 2011 9:25 PM
  • They ever add this feature?   I have the consumer preview installed.

    Software Serial Thriller

    Sunday, March 04, 2012 9:26 PM
  • I also have consumer preview and need this feature or something similar.

    Thanks


    If my response answers your question, please mark it as the "Answer" by clicking that button above my post.

    My blog: http://www.RyanVice.net/

    Wednesday, March 07, 2012 11:40 AM
  • I have the same question
    Sunday, March 18, 2012 6:28 PM
  • Guys please figure out a solution to this problem, listening to property changed events in the code behind is an MVVM killer!!!
    Tuesday, March 27, 2012 1:08 PM
  • I'd file a Connect issue so we can at least vote on it, but I can't work out what the right place to submit this would be. Anyone got any suggestions? The Windows Ecosystem Readiness Program at https://connect.microsoft.com/site1147 still only seems to be taking bug reports, and this isn't a bug as such.
    Tuesday, March 27, 2012 1:48 PM
  • Bumping this. It'd make MVVM somewhat pointless, if I'd have to unbind all textboxes in my project and replace it with a considerable amount of glue code.
    Saturday, May 26, 2012 2:53 PM
  • Bump. This feature is so needed!

    AlSki http://alski. net

    Friday, August 03, 2012 11:33 AM
  • Now, Windows 8 RTMed and this problem is still not solved! WTF?! It seems there is still no real workaround?
    Friday, October 05, 2012 3:10 PM
  • This is only solution for this particular problem (TextBox instant updating)... I'm writing custom controls and need to update the binding itself... If I set a dependency property manually, I'll lose the binding and the control is broken...
    Friday, October 05, 2012 3:49 PM
  • Here's another workaround on Stack Overflow...

    http://stackoverflow.com/questions/12692885/updatesourcetrigger-propertychanged-equivalent-for-a-textbox-in-winrt-xaml

    Shocked to see yet another key feature missing. Seems like Windows Phone 7.0 all over again :-(

    WPF and Silverlight were so cool, why not just port 100% to ARM and keep everyone happy?!

    Actually there are a load of useful WinRT, WPF and Silverlight controls by the same guy. Here's the direct link to his CodePlex "My Toolkit" homepage...

    http://mytoolkit.codeplex.com/documentation?referringTitle=Home


    Key Artefacts


    • Edited by Code Chief Tuesday, October 09, 2012 1:26 AM Add direct link.
    Tuesday, October 09, 2012 1:19 AM
  • If MS intended to make WinRT apps more responsive, by dropping this useful feature, they have presumably done the exact opposite.

    By forcing developers to come up with workarounds that tend to be less fine tuned than MS could do, MS might make apps and with it WinRT less appealing to consumers.

    Has MS ever thought of this? 

    The same might apply to other topics, too. Just by stripping features you don't make apps necessarily better, you just force developers to go more complicated ways or move away from WinRT completely

    Sunday, December 23, 2012 2:06 PM
  • Here's a behaviour I did that doesn't require subclassing the Textbox. You still have to supply the property name to the behaviour as GetBindingExpression doesn't exist.

    using System.Reflection;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    namespace Flexman
    {
        public class TextBoxUpdateSourceBehaviour
        {
            private static PropertyInfo _boundProperty;
    
            public static readonly DependencyProperty BindingSourceProperty =
                DependencyProperty.RegisterAttached(
                "BindingSource", 
                typeof(string), 
                typeof(TextBoxUpdateSourceBehaviour),
                new PropertyMetadata(default(string), OnBindingChanged));
    
            public static void SetBindingSource(TextBox element, string value)
            {
                element.SetValue(BindingSourceProperty, value);
            }
    
            public static string GetBindingSource(TextBox element)
            {
                return (string)element.GetValue(BindingSourceProperty);
            }
    
            private static void OnBindingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
            {
                var txt = d as TextBox;
                if (txt == null)
                    return;
    
                txt.Loaded += OnLoaded;
                txt.TextChanged += OnTextChanged;
            }
    
            static void OnLoaded(object sender, RoutedEventArgs e)
            {
                var txt = sender as TextBox;
                if (txt == null)
                    return;
    
                // Reflect the datacontext of the textbox to find the field to bind to.
                var dataContextType = txt.DataContext.GetType();
                _boundProperty = dataContextType.GetRuntimeProperty(GetBindingSource(txt));
    
                // If you want the behaviour to handle your binding as well, uncomment the following.
                //var binding = new Binding();
                //binding.Mode = BindingMode.TwoWay;
                //binding.Path = new PropertyPath(GetBindingSource(txt));
                //binding.Source = txt.DataContext;
                //BindingOperations.SetBinding(txt, TextBox.TextProperty, binding);
            }
    
            static void OnTextChanged(object sender, TextChangedEventArgs e)
            {
                var txt = sender as TextBox;
                if (txt == null)
                    return;
    
                if (_boundProperty.GetValue(txt.DataContext).Equals(txt.Text)) return;
                _boundProperty.SetValue(txt.DataContext, txt.Text);
            }
        }
    }

    Usage is:

    <TextBox Text="{Binding Username}" Flexman:TextBoxUpdateSourceBehaviour.BindingSource="Username" />

    You can also have the behaviour do the binding for you however have commented that part out. Means when MS do fix this in the future it's easier to swap out the behaviour.

    Enjoy!

    Glen

    • Proposed as answer by Flexman Sunday, December 23, 2012 9:13 PM
    • Unproposed as answer by Flexman Sunday, December 23, 2012 9:13 PM
    • Edited by Flexman Sunday, December 23, 2012 9:20 PM Edited to add using statements for the devs out there without resharper...
    Sunday, December 23, 2012 9:13 PM
  • I used the TextBoxUpdateSourceBehavior  in a short article I published in codePoject. However to use it on the same page with multiple TextBox controls there some little modifications to apply.

    http://www.codeproject.com/Articles/540839/Using-Smart-cards-with-a-Windows-Store-App



    Software Architect, Consitel Pte Ltd, Atrium In-Building suite



    • Edited by orouit Monday, February 11, 2013 10:04 AM
    Saturday, February 09, 2013 4:12 PM