MainWindow.xaml file.
<Window x:Class="TDNWPFApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TDNWPFApp"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<local:Attendees/>
</Window.DataContext>
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock FontSize="42" Text="{Binding Path=StudentName}" />
</StackPanel>
</Window>
In this example, we are creating a DataContext that maps to a class that we will create shortly called Attendees. We then access the Text property of the TextBlock and bind to a property set in our class. Go ahead and add a class called Attendees using the following code-snippet:
class Attendees
{
public string StudentName { get; set; }
public Attendees()
{
StudentName = "Michael Crump";
}
}
In this class, we are adding one simple property called StudentName and giving it a value of "Michael Crump" inside the constructor.
Taking a look now at the designer, you will see Intellisense working in real-time as shown in Figure 1.
[caption id="attachment_14291" align="aligncenter" width="1023"]
Figure 1: Databinding in action for XAML[/caption]
Pay special attention to the "StudentName" being auto-discovered by the XAML editor.
Figure 2: Go To Definition Support in XAML on a Variety of Elements.[/caption]
If you are tired of searching for where a specific resource was defined, it works there as well as shown in Figure 3.
[caption id="attachment_14303" align="aligncenter" width="1061"]
Figure 3: Go To Definition for Finding Resources.[/caption]
p element. I could change the code here to say something else or modify the CSS and switch back to my app to see the changes. This is a powerful new feature in Visual Studio 2013 that everyone should take advantage of. You can access it by going to Debug->Options->DOM Explorer->Show All.
[caption id="attachment_14311" align="aligncenter" width="1108"]
Figure 4: Exploring the DOM inside a Windows Store App built using WinJS.[/caption]
You'll also have access to the JavaScript Console.as shown in Figure 5.
[caption id="attachment_14321" align="aligncenter" width="795"]
Figure 5: The JavaScript Console.[/caption]
Note that I'm already signed in with my Azure account.[caption id="attachment_14331" align="aligncenter" width="770"]
Figure 6: MVC Wizard in Visual Studio 2013[/caption]
Next we need to configure the application by providing a Site Name and Region as shown in Figure 7:
[caption id="attachment_14341" align="aligncenter" width="579"]
Figure 7: Configure Azure WebSite Wizard[/caption]
Switching over to the Solution Explorer, under Azure -> Website, we now have the ability to right click on the app that we just created and select, "Attach Debugger" as shown in Figure 8.
[caption id="attachment_14351" align="aligncenter" width="423"]
Figure 8: Attaching the Debugger to the Azure Deployed Site.[/caption]
Let's set a break point on a line in our "About Page" and watch the magic happen as shown in Figure 9.
[caption id="attachment_14361" align="aligncenter" width="1024"]
Figure 9: The Debugger in Action.[/caption]
Special thanks to my colleague, Jeff Fritz for passing along this awesome feature!
Figure 10 : Adding a Guide to our Windows Store App.[/caption]
By using a predefined guide, I was able to verify that the Hub App matches the design guidelines that MS put in place and this application will look fantastic on all devices.
If my app needs a custom design, then I can simply move the ruler to match my design and even save them from the same dialog that I loaded the predefined guides.
Figure 11 : Upper Case can be toggled through the IDE now.[/caption]
Michael Crump is a Microsoft MVP, Pluralsight and MSDN author as well as an international speaker. He works at Telerik with a focus on everything mobile. You can follow him on Twitter at @mbcrump or keep up with his various blogs by visiting his Telerik Blog or his Personal Blog.