Passa ai contenuti principali

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>
     </local:MyView>
     
</local:MyPageBase>

Commenti

Post popolari in questo blog

Log.Net: Conflitto Con CrystalReport per Visual Studio 2010

Situazione: Web Application Asp.Net 4.0, Utilizzo delle librerie di Crystal Report per VS2010. Il progetto web utilizza Log.Net, scaricato dal sito ufficiale. Un problema simile si verifica con applicazioni Windows Form. Problema: Le due librerie vanno in conflitto sia in fase di compilazione ( 1550854 - "Could not load file or assembly 'log4net' or one of its dependencies" Error when building Visual Studio 2010 solution utilizing the Crystal Reports .NET Runtime ), sia una volta installata sulla macchiana target (L'inizializzatore di tipo di 'CrystalDecisions.Shared.SharedUtils' ha generato un'eccezione. Impossibile caricare il file o l'assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' o una delle relative dipendenze. La definizione di manifesto dell'assembly specificato non corrisponde al riferimento all'assembly.). Soluzione Spiegata: Il thread in cui ne parlano. A quanto ho ca...

Dotnetnuke non migrerà ad asp .NET MVC

Il grande capo di dnn Shawn Walker ha messo in chiaro che non tenteranno un porting di dnn verso asp .Net MVC, dotnetnuke resterà per sempre su web forms. La scelta è tanto saggia quanto obbligata. Esiste però un modo per estendere DNN o integrarlo con un'applicazione MVC? sembra di si, il completo tutorial in 3 parti direttamnte dai blog ufficiali delgi sviluppatori Dnn: parte1 parte2 parte3 Per completezza qui il famoso post di ScottGu sulla volontà di microsoft di tenere in piedi con uguali risorse sia asp.Net MVC sia WebForms.

Xamarin Forms Image: where to put images in projects (root directory in WindosPhone)

We have a PCL Xamarin.Forms project with some XAML. Images are project-specific so we put the image in the starting projec (i.e. Wp and Android) We want to define image name in the XAML so we use: x:Name="myImage"  Source="NavigationLeft.png" Android takes the "NavigationLeft.png" in the Resources/Drawable WindowsPhone takes the "NavigationLeft.png" on the root of the project. So Windows phone project get messed with resource images in the root folder. Is there a way to avoid this? No, there's not: in Windows Phone  we could place the image in an "Images" forder and reference it with "Images/NavigationLeft.png" in XAML, this would work. But in Android the Resource/drawable directory is a flat diretory and does allow subdirs. For now i prefixed share image with an x "xNavigationLeft". Sources: Android drawable does not allow subdirs For Wp using Xamarin.Forms we must put images on root dir