Passa ai contenuti principali

Post

Visualizzazione dei post da marzo, 2016

Xamarin Xaml Reusable Content View, basics

Simply open Xamarin Studio and create a new "Forms ContentView Xaml", name it MyView, that is our UserControl. In the code below we use the UserControl inside a Xaml Page. Without adding any code to the UserControl the page can interact with it setting its content (the label "Hello From the page"). With this approach the page decided to replace the content of the UserControl, any view added within the UserControl by xaml in itself will be ignored. The UserControl can still be extended using it's c# code-behind. <? xml version ="1.0" encoding ="UTF-8" ? > < local:MyPageBase xmlns ="http://xamarin.com/schemas/2014/forms" xmlns:x ="http://schemas.microsoft.com/winfx/2009/xaml" x:Class ="xam0001.MyPage1" xmlns:local ="clr-namespace:xam0001" > < local:MyView > < Label Text ="Hello From the page" ></ Label > </

Xamarin.Forms Reusable XAML Page Base Class

The base class is a normal XAML Page. The derived class comes from a new XAML Page, then we change: In code: public partial class MyPage1 : MyPageBase In xaml: < local:MyPageBase xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  x:Class="xam0001.MyPage1" xmlns:local="clr-namespace:xam0001" >   </ local:MyPageBase >