
Chapter 8: Building Desktop Applications with WPF | 247 |
using m_ctx, which is a field, both the Window_Loaded method and the UpdateButton_ Click method are using the same object instance. When making changes in the Grid, those changes are saved in the Order objects for the changed rows. The Order objects notify MyShopDataContext that they have changed, which is a service of LINQ to SQL. The UpdateButton_Click method uses m_ctx, which is the MyShopDataContext that knows about the changes to the Order objects. Calling SubmitChanges on m_ctx saves all changes to the database.
You might need to read the preceding paragraph more than one time to understand how this is working. If it’s still fuzzy, it might be helpful to review the language chapters earlier in this book to understand how objects are instantiated and used, and review Chapter 7 to ensure you understand the data manipulation picture.
Summary
While there is much more to learn about WPF, this is a beginner’s guide and intended to give you the essentials so that you can begin moving in the right direction. You should now be able to create a new WPF project. You learned about layout controls and how they allow you to manage how controls appear on your form. A section explains the windows involved in working with controls. While there are many controls you can use that ship with both WPF and many
This chapter introduces you to working with desktop applications, which are still very necessary and popular. However, a lot of today’s applications are written for the Internet. The next chapter shows you how to build Web applications with ASP.NET.