PhoneAppSelection

For this demonstration we supply the Oxygene and XAML code. To obtain a working version, start a new Windows PhoneApp named PhoneAppSelection and paste the Oxygene code below into MainPage.xaml.pas and the XAML code into MainPage.xaml. If you want to start from scratch, see the steps on the previous page if necessary to learn how to add components to the form and to change their properties. The code follows a screenshot of the program in action. Compare this with the equivalent code in RemObjects C#.

Screenshot after making selections

Screenshot after making selections

Oxygene code

namespace PhoneAppSelection;

interface

uses
  System,
  System.Collections.Generic,
  System.Windows.Controls,
  System.Windows.Media,
  Microsoft.Phone.Controls;

type
  MainPage = public partial class(PhoneApplicationPage)
  private
   Sizes : List<Integer> := new List<Integer>([24, 36, 48, 60, 72]);
   MessageColour : String := 'Yellow';
   MessageSize : String := '24'; 
  public
    constructor;
    method rbClick(sender: System.Object; e: System.Windows.RoutedEventArgs);
    method llsFontSize_SelectionChanged(sender: System.Object; e: System.Windows.RoutedEventArgs);
  end;

implementation

constructor MainPage;
begin
  InitializeComponent();
  llsFontSize.ItemsSource := Sizes;
  llsFontSize.FontSize := 24;
end;

method MainPage.rbClick(sender: System.Object; e: System.Windows.RoutedEventArgs);
begin
  case sender of 
    rbRed: begin
             MessageColour := 'Red';
             txtbMessage.Foreground := new SolidColorBrush(Colors.Red);
           end;
    rbBlue: begin
              MessageColour := 'Blue';
              txtbMessage.Foreground := new SolidColorBrush(Colors.Blue);
            end;
    rbGreen: begin
               MessageColour := 'Green';
               txtbMessage.Foreground := new SolidColorBrush(Colors.Green);
             end;    
  end;
  txtbMessage.Text := MessageColour + ' ' + MessageSize;
end;

method MainPage.llsFontSize_SelectionChanged(sender: System.Object; e: System.Windows.RoutedEventArgs);
begin
  txtbMessage.FontSize := Integer(llsFontSize.SelectedItem);
  MessageSize := txtbMessage.FontSize.ToString();
  txtbMessage.Text := MessageColour + ' ' + MessageSize;
end;

end.


XAML code

XAML Code
Programming - a skill for life!

How to write programs in the Oxygene for .Net dialect of Pascal