We were really excited to be at TechEd North America 2013 this week, where we participated in 15 deep, technical sessions all about Windows Phone for IT pros and enterprise developers.
Windows Phone 8 is gaining enormous traction in the enterprise and this was evident in the excitement and enthusiasm of the thousands of TechEd attendees who attended our sessions. Here’s a list of the sessions, with links to the Channel 9 page for
each session, where you can view recordings of the presentations.
Monday, June 3
Tuesday, June 4
Wednesday, June 5
Thursday, June 6
For those of you in Europe, we’ll see you at
TechEd Europe 2013 in Madrid at the end of June.
Find out more about why Windows Phone is the best choice for today’s businesses at
http://windowsphone.com/business. On this website we’ve collected critical info about Windows Phone collaboration, management, security, and enterprise app development features, along with links to deep,
technical resources and white papers.
Lire la suite
This blog post was authored by Steve White, a Senior Content Developer on the Windows Phone team.
Setting the DataContext property to a view model instance in your page markup can increase the “designability” of your pages in Visual Studio and Blend for Visual Studio. In this post I explain why, and demonstrate how it works.
So that a page’s UI elements can bind to a view model’s properties and commands, the view model is assigned to the page’s
DataContext property. A common dev practice is to set the DataContext value for a page
imperatively, using code-behind. Here’s an example from a sample app I created, called Bookstore.
- public MainPage()
- this.DataContext =
The result is a sparse design UI, on both MainPage.xaml and in the Create Data Binding dialog.
I have databound
TextBlocks and a databound
ListBox in my page. I also have an item template, which is what I’m editing in the preceding screenshot. All this runs and looks great in the Windows Phone Emulator and on Windows Phone. But that constructor isn’t executed at design time, so
my page is more challenging to style and to lay out.
Let’s see what happens if I comment out the DataContext assignment in my constructor and set the
DataContext in markup instead. To do this, first open your XAML page. Then, in the
Document Outline window, click PhoneApplicationPage; in the Properties
window, click DataContext, and then click New. Click your view model type from the Select Object dialog box, and then click
Here’s what my design surface in Visual Studio looks like now. Notice that the
Path picker in the Create Data Binding dialog is now populated, based on the
DataContext type and the properties that you can bind to.
The Create Data Binding dialog only needs a type to work from, but the bindings need the properties to be initialized with values. In my Bookstore app, I don’t want to reach out to my cloud service at design time so my initialization code checks
to see whether the app is running in a design tool such as Visual Studio or Blend.
- if (System.ComponentModel.DesignerProperties.IsInDesignTool)
- // Load design-time books.
- // Load books from a cloud service.
You could use a view model locator if you need to pass parameters to your initialization code. A view model locator is a class that you can put into app resources. It has a property that exposes the view model, and your page’s
DataContext binds to that property. Another pattern that the locator or the view model can use is dependency injection, which can construct a design-time or a run-time data provider (each of which implements a common interface), as applicable.
If for some reason none of these options work for you, you could try implementing a
design-time data context. That’s a bigger topic than we can cover here, but one way of doing it is to use the Sample Data from Class feature in Blend, and which is demonstrated
a little before the 12-minute mark in the video in the
Inside Windows Phone – Data binding blog post.
I’ll leave you with one last tip. Did you notice that Visual Studio generated the XML namespace prefix
local for the view model instance? If local is already being used elsewhere, Visual Studio generates a prefix based on the last segment of the CLR namespace. What I like to do is to use the exact CLR namespace, but replace periods with underscores.
This way I never get collisions, even if I copy-and-paste code across pages.
Lire la suite