Windows 8 Development – Data Binding Grid Title

Now that we have loaded some Feed data, we need to customize our page with some data binding.

To avoid having to worry about managing the title for each blog, we will instead data bind the title text directly to the title of the feed.

This will let us offer a consistent user experience, with a minimum of scaffolding in our code.

In this video, I will show you how to bind a data item to a grid element, and change the column span of a grid.

References

XAML Blog Reader – http://msdn.microsoft.com/en-us/library/windows/apps/br211380.aspx

Windows 8 Development – Loading State With Navigation Parameters

When we finish navigating to the SplitPage, we need to load some state information from our blog feeds.

We will do this through the familiar LoadState method, and using some simple parameter casting we will populate the title of the different blogs.

In this video, I will show you how to use a navigation parameter of type Object to load state in a new page.

References

XAML Blog Reader – http://msdn.microsoft.com/en-us/library/windows/apps/br211380.aspx

Windows 8 Development – Edit Static Text Property

By default, Visual Studio creates new projects with a title of ‘My Application’.

This is usually acceptable for a hello world application, but we will want to change this to match the intent of our application, being a Blog Reader.

We could change this resource in many ways, but we are simply going to edit the Text property as a static resource.

In this video, I will show you how to edit a static resource, namely the Text property of a TextBlock representing our page title.

References

XAML Blog Reader – http://msdn.microsoft.com/en-us/library/windows/apps/br211380.aspx

Windows 8 Development – Navigation via ItemClick Event

Now that the UI for our main application page is working, we need to add navigation to other related pages.

While we have looked at adding a navigation bar previously, we can also navigate to a new page by simply adding code to the ItemClick event handler.

Additionally, we can pass in parameters to identify the previous page, and give the target page whatever data it needs.

In this video, I will show you how to enable the ItemClick event, and add code to the ItemClick event handler.

References

XAML Blog Reader – http://msdn.microsoft.com/en-us/library/windows/apps/br211380.aspx

Windows 8 Development – XAML DefaultViewModel Binding

Next we’re going to hook up the UI for our main application page through the DefaultViewModel collection.

A page of type ‘Items’ has a default View Model defined, and it is possible to hook up to a data source with only a few lines of code.

Once done, the page will render the items in the default template format. Of course,customization will likely take place from the default settings.

In this video, I will show you how to bind our data feeds to the DefaultViewModel[“Items”] element of our ItemsPage.

References

XAML Blog Reader – http://msdn.microsoft.com/en-us/library/windows/apps/br211380.aspx

Windows 8 Development – Changing XAML Start Page

Developers familiar with Visual Studio are aware that it is possible to change the startup project via a context menu.

Similarly, when the application starts, it will load the page defined in the OnLaunched method. In order to change which page is launched, the type of the page passed in just needs to match a type within the current project which derives from LayoutAwarePage.

In this video, I will show you how to change the start page for a XAML application through the code-behind file.

References

XAML Blog Reader – http://msdn.microsoft.com/en-us/library/windows/apps/br211380.aspx

Windows 8 Development – Adding Multiple XAML Pages

Adding UI pages is a fundamental part of creating any interactive application, and can sometimes be quite time consuming.

Luckily, there are several templates to choose from which can speed up the process, and reduce development time by enabling rapid deployment of pre-defined templates.

In this video, I will show you how to add multiple pages to a XAML application.

References

XAML Blog Reader – http://msdn.microsoft.com/en-us/library/windows/apps/br211380.aspx

Windows 8 Development – XAML OnLaunched / NetworkInformation Class

Now that we’ve added our resource for the feed data, we need to override the OnLaunched method in App.xaml.

Since our application also needs to check for an internet connection, we will make use of the NetworkInformation class.

This class presents a standardized way to check for an active internet connection rather than an arbitrary DNS query, or other methods of checking for connection.

OnLaunched is called when the application is launched, and it is in this method that we’ll perform our internet check, as well as start pulling down feeds.

In this video, I will show you how to override the OnLaunched method with application specific logic, and how to use the NetworkInformation class.

References

XAML Blog Reader – http://msdn.microsoft.com/en-us/library/windows/apps/br211380.aspx

Windows 8 Development – XAML Add Resource

We’ve created a class that will handle the blog data feeds we are interested in, but now we have to incorporate that class into our program.

Using App.xaml, we can insert a named instnace of our feed data, and then later manipulate that instance to retrieve data feeds.

For those familiar with XML, XAML allows for easily defining a resource, and inserting it at an appropriate point in the schema.

In this video, I will show you how to add a resource to an application using XAML.

References

XAML Blog Reader – http://msdn.microsoft.com/en-us/library/windows/apps/br211380.aspx

Windows 8 Development – XAML Blog Reader Code Review / Await Keyword

After creating our project and copying some code from our tutorial, we will now examine that code.

The SyndicationClient makes pulling down feeds next to trivial, however to make a responsive application asynchronous programming is the best approach.

The await keyword takes care of a lot of work behind the scenes such as creating callbacks, and allows updating UI elements in the same piece of code as an asynchronous call is made, without the need to invoke any external dispatchers.

In this video, I will discuss the sample code and the asynchronous approach.

References

XAML Blog Reader – http://msdn.microsoft.com/en-us/library/windows/apps/br211380.aspx

Windows 8 Development – XAML Blog Reader Introduction

As we enter the final portion of our XAML Windows 8 series, we will start creating a meaningful application beyond our PhotoViewer, a Blog Reader.

Windows Team blogs will be chosen, but any blog that syndicates over RSS is feasible to use in our application.

In this video, I will show you how to create a new project for the Blog Reader and add a data class.

References

XAML Blog Reader – http://msdn.microsoft.com/en-us/library/windows/apps/br211380.aspx

View Controller’s life cycle

View Controller call a series of methods before loading all the views and being ready for users to interact with them. The “viewDidLoad” method is invoked first. Inside it we should do any additional setup after loading the view, typically from a nib.

There are other 4 commonly used methods that any iOS developer should know about:

– (void)viewWillAppear:(BOOL)animated
– (void)viewDidAppear:(BOOL)animated
– (void)viewWillDisappear:(BOOL)animated
– (void)viewDidDisappear:(BOOL)animated

“viewWillAppear” is called when the view is about to made visible. Default does nothing.

“viewDidAppear” is called when the view has been fully transitioned onto the screen. Default does nothing.

“viewWillDisappear” is called when the view is dismissed, covered or otherwise hidden. Default does nothing.

“viewDidDisappear” is called after the view was dismissed, covered or otherwise hidden. Default does nothing.

There are situations when we need some specific things to be done, for example to save some data if the user quits the app, and these and some other ones are the places where she to insert that logic in our projects.

How to customize the NavBar in iOS

The NavBar or the navigation bar is the top side view that appears by default over our main view if we have a navigation controller presenting the corresponding view controller.
Its dimensions for iPhone and iPod touch are 320 x 44, so if we want to set custom background images for that, we need 2 images: one normal of 320 x 44 pixels, and the other one for Retina Display, of 640 x 88 pixels.
iOS provides us 4 default options for customising the NavBar, and we do that by writing the following line of code:
self.navigationController.navigationBar.barStyle = UIBarStyleDefault;

The “barStyle” property can be set to one of 4 values, which are:
UIBarStyleDefault,
UIBarStyleBlack,
UIBarStyleBlackOpaque,
UIBarStyleBlackTranslucent.

Starting with iOS 5, it is very easy to set a background image for the NavBar in this way:
UIImage *navBarImage = [UIImage imageNamed:@”nav-bar-image”];

[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault];

Windows 8 Development – Load File Picker State XAML

Previously, we explained how to save the currently selected state of a file picker in a XAML application.

As before, however, we need to load the saved state to have the changed reflected in the relaunch of our application.

Now, we will add logic to load the state at program launch, and demonstrate the full lifecycle of data within the application.

In this video, I will show you how to load state from a file picker.

XAML File Pickers – http://msdn.microsoft.com/en-us/library/windows/apps/jj655411.aspx