Join Michael Lehman for an in-depth discussion in this video Navigating your code, part of Visual Studio 2013 for Windows Store Developers.
- View Offline
We talked a little bit about navigating code within a single file. Now let's take a look at all the different kinds of features in Visual Studio 2013 for navigating your code. Let's go ahead and once again create a new project, using the split app template. And let's go ahead and open up the items page source code file. As we mentioned before, over here in the scrollbar, wherever it is you position the cursor, the little blue line will show up. If you start making changes, you can see a yellow bar next to the lines that you've changed.
That's the basics of the scrollbar. Now, let's take a look at the scrollbar options. You can navigate within the scroll bar by right clicking and saying that you want to scroll to a specific spot, like that. You can right click here and go to the top of the file. Right click and go to the bottom of the file. Page up and page down or scroll up and scroll down. The most interesting thing is this scroll bar options. Here again, we're back in the tools option dialogue. But we're looking at the scroll bar options for the text editor. You can show a horizontal scroll bar and a vertical.
You can show annotations over the scroll bar, as we showed. Changes, marks, errors, and the caret position. By default, it uses the bar mode for the vertical scroll bar. If you recall, it's a vertical bar right here. But, we have a new feature in Visual Studio called Map Mode. And we can select that like that, select the size of our Source Overview, and we click OK. And you'll see now, in addition to being a scroll bar showing you where you are, it actually shows you the source code that's there.
So you can see where you are within the file simply by scrolling up and down. Now the really great thing is that you can do that while hovering and see the code at a large enough size to be able to see so that you can say oh I want to go down here, oh that's exactly where I want to be right there and it'll take you right directly to where you want so you can see what's underneath the cursor. So now you can navigate large files full of lots of source code and get directly where you want visually. Of course with the scroll bar you can split it so that you can have two different views, and this automatic paging code works really handy for the two different views.
You can put the views back together By pulling that separator bar back to the top or back to the bottom. Now you could also look and see that inside Visual Studio 2013 and this is in the Ultimate edition only, you have this ability to see what are the references. You can click right there and it will show you Where this particular item is referenced within your source code. You can even show it on what's called a code map. With building a code map and showing you the entire code map here. It shows you the the on launched method belongs to the items page.
And it shows up like that. Here's a video showing you how to understand complex code with code map from Microsoft. I'm not going to save the DGML file. So let's go ahead and close that. Now let's take a look at some of the direct navigation that we can see. For example, let's go ahead and go down in our source code where we start accessing our data source. There we go. Here's our load state method, and here's a call where we actually go get the groups from our sample data source and put it into this variable sample data groups.
But what if you want to see the definition of get groups a sync? Well, simply click on get groups a sync, and you can press Alt F12, and that shows you the source code from inside the sample data source file right here. Again, with its own little scroll bar. So, you can look around inside that code. You can move up and down within that code. You can see exactly where you are. Where the definition is you got this blue dot here, so you can look around inside the code without having to take your focus away from this window.
So you can see both the definition and the reference in the same code. We can go and look inside the data model, we can see that these sample data sources, a separate file over here inside the data model folder. >> So this is a really handy way of being able to look at things inside your code. Whether it's a number of references it's the definition of a particular function all in the same screen integrated in right there with your source code so that you can focus and you don't get distracted by trying to figure out which window you're in. All right, that's navigating your source code with Visual Studio 2013.
Next up we'll take a look at performance and diagnostics.
- What's new in Visual Studio 2013?
- Exploring the editor
- Invoking the compiler
- Using the debugger
- Creating apps for Windows Store
- Debugging a Windows Store app using a simulator
- Creating an account and connecting to the Windows Store
- Packaging the app