-
-
-
-
-
-
-
-
- ]]>
- ]]>
-
- (
- // o => o.Foo, default (string)
- // );
-
- public string BoundName
- {
- get { return (string) GetValue (BoundNameProperty); }
- set { SetValue (BoundNameProperty, value); }
- }
-}
- ]]>
-
-
-
-
- (w => w.My, default(string));
-
- public string My {
- get { return (string)GetValue (MyProperty); }
- set { SetValue (MyProperty, value); }
- }
-}
- ]]>
-
- (w => w.My, default(string));
-
- public string My {
- get { return (string)GetValue (MyProperty); }
- set { SetValue (MyProperty, value); }
- }
-}
- ]]>
- (w => w.My, default(string));
- public static readonly BindableProperty MyProperty = MyPropertyKey.BindableProperty;
-
- public string My {
- get { return (string)GetValue (MyProperty); }
- internal set { SetValue (MyPropertyKey, value); }
- }
-}
- ]]>
-
-
- (Label.TextProperty, vm => vm.Name);
-label.BindingContext = new PersonViewModel {
- Name = "John Doe",
- Company = "Xamarin"
-};
-Debug.WriteLine (label.Text); //prints "John Doe"
- ]]>
- (w => w.Foo, default(string));
-
- public static readonly BindableProperty FooProperty = FooPropertyKey.BindableProperty;
-
- public string Foo {
- get { return (string)GetValue (FooProperty); }
- internal set { SetValue (FooPropertyKey, value); }
- }
-}
- ]]>
-
-
- (vm => vm.Name));
-Debug.WriteLine (label.Text); //prints "John Doe".
- ]]>
-
- ]]>
- (Label.TextProperty, vm => vm.Name, mode: BindingMode.OneWay);
-
-viewmodel.Name = "John Doe";
-Debug.WriteLine (label.Text); //prints "John Doe"
-label.Text = "Foo";
-Debug.WriteLine (viewmodel.Name); //prints "John Doe"
-
-
-//BindingMode.TwoWay
-label = new Label ();
-label.BindingContext = viewmodel = new PersonViewModel ();
-label.SetBinding (Label.TextProperty, vm => vm.Name, mode: BindingMode.TwoWay);
-
-viewmodel.Name = "John Doe";
-Debug.WriteLine (label.Text); //prints "John Doe"
-label.Text = "Foo";
-Debug.WriteLine (viewmodel.Name); //prints "Foo"
-
-
-//BindingMode.OneWayToSource
-label = new Label ();
-label.BindingContext = viewmodel = new PersonViewModel ();
-label.SetBinding (Label.TextProperty, vm => vm.Name, mode: BindingMode.OneWayToSource);
-
-viewmodel.Name = "John Doe";
-Debug.WriteLine (label.Text); //prints ""
-label.Text = "Foo";
-Debug.WriteLine (viewmodel.Name); //prints "Foo"
- ]]>
- ]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]>
- pages = new List (0);
-Color[] colors = { Color.Red, Color.Green, Color.Blue };
-foreach (Color c in colors) {
- pages.Add (new ContentPage { Content = new StackLayout {
- Children = {
- new Label { Text = c.ToString () },
- new BoxView {
- Color = c,
- VerticalOptions = LayoutOptions.FillAndExpand
- }
- }
- }
- });
-}
-
-MainPage = new CarouselPage {
- Children = { pages [0],
- pages [1],
- pages [2] }
-};
-]]>
-
-
- Hello, World!
-]]>
-
- Hello, World!
- Color.Blue
-]]>
-
-
-
-
-
-
-]]>
-
-
-
-
-
-]]>
- Debug.WriteLine ("Command executed"));
-var button = new Button {
- Text = "Hit me to execute the command",
- Command = command,
-};
-]]>
- Debug.WriteLine ("Command executed: {0}", o));
-var button = new Button {
- Text = "Hit me to execute the command",
- Command = command,
- CommandParameter = "button0",
-};
-]]>
- (s => Debug.WriteLine ("Command executed: {0}", s));
-var button = new Button {
- Text = "Hit me to execute the command",
- Command = command,
- CommandParameter = "button0",
-};
-]]>
-
-
-
-This is equivalent to the following, more explicit XAML
-
-
-
-
- ]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-]]>
-
-
-
- yyyy-MM-dd
-
-
-
- Jan 1 2000
-
-
-
-
-
-
- Dec 31 2050
-
-
-
-
- ]]>
- (DependencyFetchTarget.NewInstance);
- ]]>
- {
- label.Text = "Async operation completed";
-});
- ]]>
- label.Font = Font.OfSize ("HelveticaNeue-UltraLight", NamedSize.Large));
- ]]>
-
-
-
-
-
-
-
-{
- protected override void Invoke(Entry sender)
- {
- Color[] color ={ Color.Red,
- Color.Orange,
- Color.Yellow,
- Color.Green,
- Color.Blue,
- Color.Indigo,
- Color.Violet };
- sender.TextColor = color[sender.Text.Length % color.Length];
- }
-}]]>
-
-
-
-
-
-
-
-
-
-
-
-
- ]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]>
- {
- {"Keyboard.Default", Keyboard.Default},
- {"Keyboard.Email", Keyboard.Email},
- {"Keyboard.Text", Keyboard.Text},
- {"Keyboard.Url", Keyboard.Url},
- {"Keyboard.Telephone", Keyboard.Telephone},
- {"Keyboard.Chat", Keyboard.Chat},
-})
-Assert.AreSame (kvp.Value, converter.ConvertFrom (kvp.Key));
- ]]>
-
-
- layout, IEnumerable newItems)
- {
- layout.Children.Clear ();
- foreach (var item in newItems) {
- layout.Children.Add (item);
- }
- }
- ]]>
-
- people = new List
- {
- new Person("Abigail", new DateTime(1975, 1, 15), Color.Aqua),
- new Person("Bob", new DateTime(1976, 2, 20), Color.Black),
- // ...etc.,...
- new Person("Yvonne", new DateTime(1987, 1, 10), Color.Purple),
- new Person("Zachary", new DateTime(1988, 2, 5), Color.Red)
- };
-
- // Create the ListView.
- ListView listView = new ListView
- {
- // Source of data items.
- ItemsSource = people,
-
- // Define template for displaying each item.
- // (Argument of DataTemplate constructor is called for
- // each item; it must return a Cell derivative.)
- ItemTemplate = new DataTemplate(() =>
- {
- // Create views with bindings for displaying each property.
- Label nameLabel = new Label();
- nameLabel.SetBinding(Label.TextProperty, "Name");
-
- Label birthdayLabel = new Label();
- birthdayLabel.SetBinding(Label.TextProperty,
- new Binding("Birthday", BindingMode.OneWay,
- null, null, "Born {0:d}"));
-
- BoxView boxView = new BoxView();
- boxView.SetBinding(BoxView.ColorProperty, "FavoriteColor");
-
- // Return an assembled ViewCell.
- return new ViewCell
- {
- View = new StackLayout
- {
- Padding = new Thickness(0, 5),
- Orientation = StackOrientation.Horizontal,
- Children =
- {
- boxView,
- new StackLayout
- {
- VerticalOptions = LayoutOptions.Center,
- Spacing = 0,
- Children =
- {
- nameLabel,
- birthdayLabel
- }
- }
- }
- }
- };
- })
- };
-
- // Accomodate iPhone status bar.
- this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
-
- // Build the page.
- this.Content = new StackLayout
- {
- Children =
- {
- header,
- listView
- }
- };
- }
- }
-}
-
-]]>
-
-
- {
- public Group (string firstInitial)
- {
- FirstInitial = firstInitial;
- }
-
- public string FirstInitial
- {
- get;
- private set;
- }
- }
- ]]>
-
-
-
-{
- public Group (string firstInitial)
- {
- FirstInitial = firstInitial;
- }
-
- public string FirstInitial
- {
- get;
- private set;
- }
-}
- ]]>
-
-
-
-
-
-
-
-
-
-]]>
-
- {
- this.IsPresented = true;
- }));
- }
-
- // Define a selected handler for the ListView.
- listView.ItemSelected += (sender, args) =>
- {
- // Set the BindingContext of the detail page.
- this.Detail.BindingContext = args.SelectedItem;
-
- // Show the detail page.
- this.IsPresented = false;
- };
-
- // Initialize the ListView selection.
- listView.SelectedItem = namedColors[0];
-
-
- }
- }
-}
- ]]>
- (subscriber, "IntPropertyMessage", (s, e) => {
- subscriber.IntProperty = e;
-});
-
-//...later...
-
-MessagingCenter.Send(this, "IntPropertyMessage", 2);
-Assert.AreEqual(2, subscriber.IntProperty);
- ]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]]>
-
- {
-
- GL.ClearColor (red, green, blue, 1.0f);
- GL.Clear ((ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));
-
- red += 0.01f;
- if (red >= 1.0f)
- red -= 1.0f;
- green += 0.02f;
- if (green >= 1.0f)
- green -= 1.0f;
- blue += 0.03f;
- if (blue >= 1.0f)
- blue -= 1.0f;
- };
-
- toggle.Toggled += (s, a) => {
- view.HasRenderLoop = toggle.IsToggled;
- };
- button.Clicked += (s, a) => view.Display ();
-
- var stack = new StackLayout {
- Padding = new Size (20, 20),
- Children = {view, toggle, button}
- };
-
- Content = stack;
- }
- }
-}
-
- ]]>
- {
-
- GL.ClearColor (red, green, blue, 1.0f);
- GL.Clear ((ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));
-
- red += 0.01f;
- if (red >= 1.0f)
- red -= 1.0f;
- green += 0.02f;
- if (green >= 1.0f)
- green -= 1.0f;
- blue += 0.03f;
- if (blue >= 1.0f)
- blue -= 1.0f;
- };
- ]]>
- nameToColor = new Dictionary
- {
- { "Aqua", Color.Aqua }, { "Black", Color.Black },
- { "Blue", Color.Blue }, { "Fucshia", Color.Fucshia },
- { "Gray", Color.Gray }, { "Green", Color.Green },
- { "Lime", Color.Lime }, { "Maroon", Color.Maroon },
- { "Navy", Color.Navy }, { "Olive", Color.Olive },
- { "Purple", Color.Purple }, { "Red", Color.Red },
- { "Silver", Color.Silver }, { "Teal", Color.Teal },
- { "White", Color.White }, { "Yellow", Color.Yellow }
- };
-
- public PickerDemoPage()
- {
- Label header = new Label
- {
- Text = "Picker",
- FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
- HorizontalOptions = LayoutOptions.Center
- };
-
- Picker picker = new Picker
- {
- Title = "Color",
- VerticalOptions = LayoutOptions.CenterAndExpand
- };
-
- foreach (string colorName in nameToColor.Keys)
- {
- picker.Items.Add(colorName);
- }
-
- // Create BoxView for displaying picked Color
- BoxView boxView = new BoxView
- {
- WidthRequest = 150,
- HeightRequest = 150,
- HorizontalOptions = LayoutOptions.Center,
- VerticalOptions = LayoutOptions.CenterAndExpand
- };
-
- picker.SelectedIndexChanged += (sender, args) =>
- {
- if (picker.SelectedIndex == -1)
- {
- boxView.Color = Color.Default;
- }
- else
- {
- string colorName = picker.Items[picker.SelectedIndex];
- boxView.Color = nameToColor[colorName];
- }
- };
-
- // Accomodate iPhone status bar.
- this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
-
- // Build the page.
- this.Content = new StackLayout
- {
- Children =
- {
- header,
- picker,
- boxView
- }
- };
-
- }
- }
-}
-]]>
-
-
-
-
-
-
-
-
-
-
-]]>
-
-
- {
- return 0;
- }));
-
- relativeLayout.Children.Add (relativelyPositioned,
- Constraint.RelativeToParent ((parent) => {
- return parent.Width / 3;
- }),
- Constraint.RelativeToParent ((parent) => {
- return parent.Height / 2;
- }));
- this.Content = relativeLayout;
- }
-}
-]]>
-
-
-
-
-
-
-
-
-
-]]>
-
- {resultsLabel.Text = "Result: " + searchBar.Text + " is what you asked for.";})
- };
-
- MainPage = new ContentPage {
- Content = new StackLayout {
- VerticalOptions = LayoutOptions.Start,
- Children = {
- new Label {
- HorizontalTextAlignment = TextAlignment.Center,
- Text = "SearchBar",
- FontSize = 50
- },
- searchBar,
- new ScrollView
- {
- Content = resultsLabel,
- VerticalOptions = LayoutOptions.FillAndExpand
- }
- },
- Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5)
- }
- };
- }
-
- // OnStart, OnSleep, and OnResume implementations, & etc.
-
-}]]>
-
-
-
-
-
- Developers should be aware that implicit styles are only applied to the specific type that is described by
-
- {
- return new NamedColorPage ();
- });
- }
- }
-
- // Data type:
- class NamedColor
- {
- public NamedColor (string name, Color color)
- {
- this.Name = name;
- this.Color = color;
- }
-
- public string Name { private set; get; }
-
- public Color Color { private set; get; }
-
- public override string ToString ()
- {
- return Name;
- }
- }
-
- // Format page
- class NamedColorPage : ContentPage
- {
- public NamedColorPage ()
- {
- // This binding is necessary to label the tabs in
- // the TabbedPage.
- this.SetBinding (ContentPage.TitleProperty, "Name");
- // BoxView to show the color.
- BoxView boxView = new BoxView {
- WidthRequest = 100,
- HeightRequest = 100,
- HorizontalOptions = LayoutOptions.Center
- };
- boxView.SetBinding (BoxView.ColorProperty, "Color");
-
- // Build the page
- this.Content = boxView;
- }
- }
-}
-
-
-]]>
-
-
-
-
-
-
-
-
-]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-]]>
-
-{
- protected override void Invoke(Entry sender)
- {
- sender.TextColor = Color.Red;
- }
-}]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-]]>
-
-{
- protected override void Invoke(Entry sender)
- {
- sender.TextColor = Color.Red;
- }
-}]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-]]>
- image.Opacity = 0.5,
- NumberOfTapsRequired = 2
- };
- image.GestureRecognizers.Add (gestureRecognizer);
- ]]>
-
-
- button2.IsEnabled = false;
- }
- }
- ]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-]]>
- ]]>
-
-
-
-
-