How do I update a single item in an ObservableCollection class?

You can’t generally change a collection that you’re iterating through (with foreach). The way around this is to not be iterating through it when you change it, of course. (x.Id == myId and the LINQ FirstOrDefault are placeholders for your criteria/search, the important part is that you’ve got the object and/or index of the object) … Read more

WPF/Silverlight – Prism – Resources for beginners

I’ve been creating Prism (Silverlight slant but most applies to WPF as well) resources: If you have 5 minutes: 10 Things to Know About Prism If you have 20 minutes: Prism Basics Video videos Intro to Silverlight Prism Testing/Module Catalog/Unity Regions (including Region Scope, Region Adapter and Region Context) Commanding (including creating new commands) Eventing … Read more

How do I raise an event in a usercontrol and catch it in mainpage?

Check out Event Bubbling — http://msdn.microsoft.com/en-us/library/aa719644%28vs.71%29.aspx Example: User Control public event EventHandler StatusUpdated; private void FunctionThatRaisesEvent() { //Null check makes sure the main page is attached to the event if (this.StatusUpdated != null) this.StatusUpdated(this, new EventArgs()); } Main Page/Form public void MyApp() { //USERCONTROL = your control with the StatusUpdated event this.USERCONTROL.StatusUpdated += new EventHandler(MyEventHandlerFunction_StatusUpdated); … Read more

TextBox Binding TwoWay Doesn’t Update Until Focus Lost WP7

I assume your Save button is an ApplicationBarButton (not a normal button). For normal buttons it will just work because they take focus and hence the data-binding will kick in. For ApplicationBarButtons on the phone it’s a little different because they don’t take focus away from the client app. To ensure the data-binding kicks in … Read more

How do you force Firefox to not cache or re-download a Silverlight XAP file?

The query string works perfectly, but I wouldn’t use DateTime.Now, because it forces the user to re-download the app every time. Instead, we use the following: protected void Page_Load(object sender, EventArgs e) { var versionNumber = Assembly.GetExecutingAssembly().GetName().Version.ToString(); this.myApp.Source += “?” + versionNumber; } This way all you have to do is increment the version number … Read more