Oxygene

Oxygene and WP8 – Navigation in Windows Phone 8 (Part2)

Pass data between Pages in Windows Phone

One of the most common task when performing the navigation in a windows phone app is to pass the data from one page to another.

The NavigationContext in Windows Phone enables the developers to pass the QueryString from the source page and retrieve it in the destination page.

To send the data from the source page to the destination , the value has to be passed as parameter along with the Uri as shown below

NavigationService.Navigate(new Uri("/MainPage2.xaml?Message=User is SenthilKumar", UriKind.Relative));

Read more

Oxygene and WP8 – Navigation in Windows Phone 8

The Windows Phone 8 SDK provides the Navigate method defined in the NavigationService which lets the developers to provide ability for the user to navigate from one page to another.

For example , imagine you have a page called “menu.xaml” which contains the list of menu within your application . On clicking of one of the menu button , the user needs to navigate to a different page . In this case , you can use the NavigationService to navigate from one page to another.

Simple Navigation in Windows Phone 8

In this example , let’s assume there are 2 pages “MainPage1.xaml” and “MainPage2.xaml” . The MainPage1.xaml has a button and on click of it the page has to be navigated from MainPage1.xaml to MainPage2.xaml.

method MainPage.Button_Click_1(sender: Object; e: System.Windows.RoutedEventArgs);

begin

   NavigationService.Navigate(new Uri("/MainPage2.xaml", UriKind.Relative));

end;

Read more

Oxygene and WP8 – How to Create Application Bar using Oxygene?

In one of the previous article , we saw how to create Application Bar using XAML in a WP8 Oxygene project. This article will explain how to create How to Create Application Bar using Oxygene Code at runtime .

Oxygene and WP8 – How to Create Application Bar using Oxygene?

The ApplicationBar to the page can be added via Oxygene code without touching the XAML code. Follow the below steps to add application bar using Oxygene

1. Launch Visual Studio 2012 and open the WP8 Project.

2. Add the images for the Application Bar icon buttons to the project. The common icons for the ApplicationBar that is part of the Windows Phone 8 SDK can be found at “C:Program Files (x86)Microsoft SDKsWindows Phonev8.0IconsDark”.

3. Include the namespace Microsoft.Phone.Shell in the code behind file.

uses Microsoft.Phone.Shell;

4. Initialize the ApplicationBar and create ApplicationBarIconButton and add it to the application bar. In this example , we will create 2 ApplicationBarIconButton with edit and cancel icons.

ApplicationBar := new ApplicationBar();

var appBarIconButton: ApplicationBarIconButton := new ApplicationBarIconButton(new Uri('/Assets/edit.png', UriKind.RelativeOrAbsolute));

appBarIconButton.Text := 'Save';

ApplicationBar.Buttons.Add(appBarIconButton);

var appBarIconButtonCancel: ApplicationBarIconButton := new ApplicationBarIconButton(new Uri('/Assets/cancel.png', UriKind.RelativeOrAbsolute));

appBarIconButtonCancel.Text := 'Cancel';

ApplicationBar.Buttons.Add(appBarIconButtonCancel);

Read more

Oxygene and WP8 – Application Bar in Windows Phone 8

The Application Bar in Windows Phone is commonly called as AppBar provides the users with easy and quick access to the Windows Phone app’s common functionalities.

The Application Bar is a row that contains icon buttons and ellipsis . When the user taps on the ellipsis , the menu items(if enabled) are shown. The menu items are the text based menu items that are displayed in a list when the ellipsis is tapped.

How to Create ApplicationBar using XAML ?

One of the quickest way to create Application Bar in Windows Phone is using XAML or XAML Designer.

Follow the below steps to create Application Bar using XAML.

1. In Visual Studio 2012 , Open your Windows Phone Page in the Designer to view the XAML code.

2. In the Windows Phone page (Eg : MainPage.xaml) , add the following code to create an ApplicationBar with 2 IconButtons and one menu item.

<phone:PhoneApplicationPage.ApplicationBar>
  <shell:ApplicationBar>
    <shell:ApplicationBar.MenuItems>
      <shell:ApplicationBarMenuItem IsEnabled="True" Text="About Us" Click="ApplicationBarIconButton_Click_1"/>
    </shell:ApplicationBar.MenuItems>
    <shell:ApplicationBarIconButton IconUri="/Assets/edit.png" IsEnabled="True" Text="Edit"/>
    <shell:ApplicationBarIconButton IconUri="/Assets/cancel.png" IsEnabled="True" Text="Cancel" />
  </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

Read more

Oxygene and WP8 – Binding to LongListSelector via DataTemplate

DataTemplate lets the developers use multiple controls or elements within the ItemsControl, ListBox and LongListSelector controls.

In one of the previous articles , we explained how to bind collection to ItemsControl.

In this article , we will extend or modify the same example to display the Collection in LongListSelector using DataTemplate.

Oxygene and WP8 – Binding to LongListSelector via DataTemplate

1. Let’s assume that we have the Employee class which needs to be utilized for displaying it on the UI.

type
 Employee = public class
 public
   property Name: System.String;
   property Designation: System.String;
 end;

Read more

Oxygene and WP8 – Binding Collections to ItemsControl

The ItemsControl in Windows Phone has the ItemsSource property which can be assigned a collection such as Lists or Arrays . This example demonstrates how to bind the collection to the ItemsSource property of the ItemsControl and display the items in the page.

Oxygene and WP8 – Binding Collections to ItemsControl

1. Let’s assume that we have the Employee class which needs to be utilized for displaying it on the UI.

type
 Employee = public class
 public
  property Name: System.String;
  property Designation: System.String;
end;

Read more

Oxygene and WP8 – Binding Data in Windows Phone

Data Binding is one of the important concept in Windows Phone 8. The Data Binding is generally done with the DataContext property which is part of the Framework Element.

Oxygene and WP8 – Binding Data in Windows Phone

For example , assume that the Object that needs to be used of Type Employee as shown below.

type
Employee = public class
  public
    property Name: System.String;
    property Designation: System.String;
end;

Read more

Oxygene and WP8 – Templates in XAML

There are 2 different types of templates which the developers can use to customize the controls . These include.

  • ControlTemplate
  • DataTemplate

ControlTemplate

The ControlTemplate can be used to customize the look of the control without affecting its behavior.

One of the drawbacks of the Style element when compared to the ControlTemplate is that the Style can only be used to set the properties that are available in the TargetType Control.

With the ControlTemplate , one can access the complete primitive parts that make up a control.

Below is a sample code snippet that demonstrates how to use the ControlTemplate to display rounded corner for the button.

<Button x:Name="btnLaunch" >
  <Button.Template>
    <ControlTemplate>
      <Border CornerRadius="20"
        BorderThickness="10"
        BorderBrush="White">
        <TextBlock>
          LaunchMobileOSGeek Website
        </TextBlock>
      </Border>
    </ControlTemplate>
  </Button.Template>
</Button>

Read more

Oxygene and WP8 – Resources and Styles in Windows Phone

There are generally two kinds of resources in XAML , the resource file with extension of resx and the resource file with xaml extension.

The resx file is generally concerned with the localization strings whereas the other one with xaml extension allows the developers to define the style or properties in separate location and then reuse these resources . This article will explain how to use the resources for reusing the styles in Windows Phone.

For example , assume the button with the following style.

<Button x:Name="btnLaunch" Content="LaunchMobileOSGeek Website" Background="Blue" BorderBrush="Yellow" BorderThickness="1" />

Read more

Oxygene and WP8 – MarketplaceReviewTask Launcher

The MarketplaceReviewTask launcher is used to launch the Windows Phone Store and display the review page of the current windows phone app .

How to use the MarketplaceReviewTask Launcher in Windows Phone 8 using Oxygene ?

To use the MarketplaceReviewTask Launcher in Windows Phone 8 with Oxygene, follow the below steps.

1. Include the following namespace in the code behind file.

uses

Microsoft.Phone.Tasks;

2. Create an instance of the MarketplaceReviewTask and invoke the Show method of the MarketplaceReviewTask object .

var marketplaceReviewTask: MarketplaceReviewTask := new MarketplaceReviewTask();
marketplaceReviewTask.Show();

Read more