Jaime Rodriguez On Windows Store apps, Windows Phone, HTML and XAML
Yesterday, Kevin Marshall wrote a blog post with a good developer tip: to code defensively for the 15 application limit in push notification. I know the post was well intended (as a developer tip) and fair criticism (to platform limit); but a few people got confused or misinterpreted and we ended up with tweets or posts that said “Windows phone allows only 15 live tiles”, or “you must uninstall apps to free tiles”, etc.. Here are a few details you might care to know, so you can plan your app and be a good citizen:
To handle the error, as Kevin pointed out it is just a matter of listening for the exception, and right error message. Then prompt user to turn-off push notifications in another app. There is no API to list the applications using it – and I have not heard of a plan for this API –.
Is the limit too low, Kevin wonders. Obviously there is no perfect answer as it varies by user. I do know that the product team did research on types of apps, categories, how many a typical user would pin, enable push, etc. and they went with 15 for v1, so it is not an arbitrarily low number. I saw the data and it made good sense to me. I also hear that the limit can increase later, as we get more apps and better data. Full clarification, “can increase” only means we are constantly evaluation. it does not mean the next update will have this limit increased. Nothing to announce. Again, the key there is the planning was done for typical users. As developers, we tend to install more apps, and often enable the features just to try them out, but we are also power users that know when and how to turn these off. On the rest, we will have to trust (and hope) that the data the researchers and planners had for typical users holds us until the limit is increased. Why is there a limit? The usual thrive to ensure there is a great user experience, good battery life, quality of service on back-end and front-end, bandwidth (cost) , etc. Limit will increase as we get right data on how people use push, impact, etc. Kevin’s feedback on there not being an API to enumerate all push apps is still valid. I know the product team has heard it (from Kevin, me and others) so I hope that gets addressed or the limits go high enough that the problem becomes a moot point.
Hope that helps. My take, when it comes to push,
Happy Windows Phone coding!
I am writing this tiny demo app, that has a TextBox data bound to a ViewModel. I want the TextBox to fire notifications to the ViewModel whenever the text changes (as opposed to only firing notifications when the textbox loses focus). In WPF, this is trivial to do, you just set the UpdateSourceTrigger on the Binding to PropertyChanged (in fact, I think that is the default). On the phone, I only see UpdateSourceTrigger supporting:
What to do? [12/5 (Update part 1) -- Updating this post due to enough feedback that the semantic of TextChanged is better than my post’s KeyUp. I did try that before suggesting KeyUp on my original post but I was seeing TextChanged fire more often than KeyUp (aka more times than I felt necessary). Now that I have seen there is no big perf hit (since others are doing it with TextChanged) I am back to proper semantics. Also you made me second guess and I tested on a keyboard and noticed that arrows can even the score firing KeyUp events.
How about:
Here are the snippets: In my XAML,
1: <TextBox x:Name="empIdTextBox" Text="{Binding Id, Mode=TwoWay, UpdateSourceTrigger=Explicit}"
2: TextChanged="empIdTextBox_TextChanged"/>
1: private void empIdTextBox_TextChanged(object sender, TextChangedEventArgs e)
2: {
3: TextBox box = (TextBox)sender;
4: BindingExpression be = box.GetBindingExpression(TextBox.TextProperty);
5: be.UpdateSource();
6:
7: }
1: public class UpdateSourceOnTextChangedBehavior : Behavior<TextBox>
3:
4: protected override void OnAttached()
5: {
6: base.OnAttached();
7: this.AssociatedObject.TextChanged += this.OnTextChanged;
8: }
9:
10: private void OnTextChanged(object sender, TextChangedEventArgs e)
11: {
12: BindingExpression be =
13: this.AssociatedObject.GetBindingExpression(TextBox.TextProperty);
14: be.UpdateSource();
15: }
16:
17: protected override void OnDetaching()
18: {
19: base.OnDetaching();
20: this.AssociatedObject.TextChanged -= this.OnTextChanged;
21: }
22: }
1: <TextBox x:Name="empIdTextBox" Grid.Column="1"
2: Text="{Binding Id, Mode=TwoWay,UpdateSourceTrigger=Explicit}" >
3: <interactivity:Interaction.Behaviors>
4: <local:UpdateSourceOnTextChangedBehavior />
5: </interactivity:Interaction.Behaviors>
6: </TextBox>
Yesterday I did a dry-run of my performance talk for today’s Silverlight fire starter.
Conclusion was that the talk is like drinking from a fire-hose. It is tight for 45 minutes, but the content is good and we could not agree on what to cut. It was all too good and useful to cut stuff.
So, I am going to cheat and give you an early preview and a guide to make it easy to follow along.
Join me today at 4:30 PST. Live at Silverlight fire starter. if you can’t make it, check later for final document, including a part 2 and the video recording.