Tag Archives: XAML

XAML Inheritance in Xamarin


via XAML Inheritance.

I  recently worked with a client who had data that he wanted to filter in various ways.   For example, he might want to show all his books, or just the fiction or just the non-fiction or just the biographies.  His chosen UI was to use tabs

How to disable Xamarin Forms XAML Intellisense in VS 2015


In addition to this manual workaround, we’ll post an updated Xamarin.Forms pre-release nuget package that won’t provide the design assemblies to XAML and will stop the crash from happening. But that won’t turn off XAML intellisense, which will be all red (as it is without the 1.5-pre nuget). http://www.cazzulino.com/xaml-forms-intellisense.html

BUILD: What’s new for XAML in Visual Studio 2015


At the Build Conference, there were many announcements in the field of development. On of these Areas are the upcoming features of Visual Studio 2015, in this case about new tools and functions for XAML. Here are the major updates, which have been shown.

https://mariofraiss.wordpress.com/2015/05/03/build-whats-new-for-xaml-in-visual-studio-2015/

Create an IBDesignable UIView subclass with code from an XIB file in Xcode 6


via Create an IBDesignable UIView subclass with code from an XIB file in Xcode 6 — iPhoneDev.tv.

f you are using Xamarin.Forms to develop a UI for your mobile app, then you probably feel crippled by the lack of a designer. It can take a couple of minutes when making a simple change in your XAML file until you can see your change in action on your favorite emulator or device. This lag is known to cause a lot of frustration for developers working on UI design and can negatively influence productivity.

Xamarin recognized the need for a designer and announced at Evolve ’14 that they are working on a live renderer that could bridge the gap. The whole community has been patiently waiting and hoping for a solution. Finally, Daniel Cazzulino from the Xamarin VS team announced the initial version of the Xamarin Forms Player a few weeks ago.

The Xamarin Forms Player app enables UI developers to preview their XAML page almost real-time. It is accompanied by a Visual Studio extension that connects to a device running Xamarin.Forms.Player app. Every time you save a XAML page in Visual Studio, it will be pushed to the device and you’ll be able to preview it, and even interact with it.

Building Cross-Platform Applications Overview


via Building Cross Platform Applications Overview – Xamarin.

Overview

This guide introduces the Xamarin platform and how to architect a cross-platform application to maximize code re-use and deliver a high-quality native experience on all of the main mobile platforms: iOS, Android and Windows Phone.

The approach used in this document is generally applicable to both productivity apps and game apps, however the focus is on productivity and utility (non-game applications). See the [Introduction to MonoGame document] for cross-platform game development guidance.

The phrase “write-once, run everywhere” is often used to extol the virtues of a single codebase that runs unmodified on multiple platforms. While it has the benefit of code re-use, that approach often leads to applications that have a lowest-common-denominator feature-set and a generic-looking user interface that does not fit nicely into any of the target platforms.

Xamarin is not just a “write-once, run everywhere” platform, because one of its strengths is the ability to implement native user interfaces specifically for each platform. However, with thoughtful design it’s still possible to share most of the non-user interface code and get the best of both worlds: write your data storage and business logic code once, and present native UIs on each platform. This document discusses a general architectural approach to achieve this goal.

Here is a summary of the key points for creating Xamarin cross-platform apps:

  • Use C# – Write your apps in C#. Existing code written in C# can be ported to iOS and Android using Xamarin very easily, and obviously used on Windows Phone.
  • Utilize the MVC design pattern – Develop your application’s User Interface using the Model/View/Controller pattern. Architect your application using a Model/View/Controller approach or a Model/View/ViewModel approach where there is a clear separation between the “Model” and the rest. Determine which parts of your application will be using native user interface elements of each platform (iOS, Android, Windows Phone and Windows 8/RT) and use this as a guideline to split your application into two components: “Core” and “User-Interface”.
  • Build native UIs – Each OS-specific application provides a different user-interface layer (implemented in C# with the assistance of native UI design tools):
    1. On iOS, use the MonoTouch.UIKit APIs to create native-looking applications, optionally utilizing Xamarin’s iOS designer to create your UI visually.
    2. On Android, use Android.Views to create native-looking applications, taking advantage of Xamarin’s UI designer
    3. On Windows Phone you will be using the XAML/Silverlight presentation layer, using Visual Studio or Blend’s UI designer
    4. On Windows 8, use the Metro APIs to create a native user experience.

The amount of code re-use will depend largely on how much code is kept in the shared core and how much code is user-interface specific. The core code is anything that does not interact directly with the user, but instead provides services for parts of the application that will collect and display this information.

To increase the amount of code re-use, you can adopt cross-platform components that provide common services across all these systems such as:

  1. SQLite-NET for local SQL storage,
  2. Xamarin.Mobile for accessing device-specific capabilities including the camera, contacts and geolocation,
  3. Using framework features for networking, web services, IO and more.

Some of these components are implemented in the Tasky case study.

Xamarin Forms For Windows Preview First Steps


via Xamarin Forms For Windows Preview First Steps.

The past March 19th, James Montemagno with Miguel de Icaza and Scott Hanselman presented a new preview version of Xamarin Forms with support for Windows Store and Windows Phone projects, during the second day of DotNetConf 2015. You can have a look at the original video here at Channel9.
The support for Windows XAML and universal projects in Xamarin.Forms was something developers have been waiting for for a long time now. To date, Xamarin.Forms only supports Windows Phone 8.0 Silverlight projects, making it unable to use some scenarios.
This release is just in preview mode, but you can start playing with it and have a look at what will come in the future and start supporting Universal Apps in your Forms solutions.

A COMPREHENSIVE GUIDE TO CREATING A XAMARIN.FORMS APP WITH MVVM CROSS


via A Comprehensive Guide to Creating a Xamarin.Forms App with MvvmCross (Part 1 of 5) – Magenic’s blog brings ideas from the technology industries thought leaders.

Xamarin.Forms is a cool addition to the Xamarin offering. Xamarin.Forms is a layer built on top of Xamarin that allows developers to create apps for Android, iOS, and Windows Phone using a single codebase. This lowers the barrier of entry significantly for .NET developers to write mobile apps. Xamarin.Forms offers a suite of controls and layouts that can be used to build up applications that will look like native applications on each of the supported platforms. These controls allow developers to add a mobile user interface to their applications which will interact with their .NET code under the hood. Being able to work in the familiar .NET environment and leverage existing .NET code is a huge plus for .NET developers.

Xamarin.Forms provides two different ways to build up the mobile UI: using C# code and using XAML. If you are comfortable working with XAML from other technologies, such as Windows Presentation Foundation, Silverlight, Windows Phone, or Windows Store apps, I highly recommend taking the time to learn how to work with XAML in Xamarin.Forms. The XAML is different in Xamarin.Forms, but it will be familiar while still providing the power of data binding and templating that you have (hopefully) come to know and love. Along with the other XAML technologies came the concept of Model-View-ViewModel (MVVM) and Xamarin.Forms is no different. In fact, Xamarin.Forms has its own MVVM functionality built-in.

If you are planning to only write a Xamarin.Forms app, without any additional apps on different platforms, the built-in MVVM functionality may suit your needs just fine. However, if you’re interested in also creating, say, Universal Windows apps alongside your Xamarin.Forms apps, you’ll need to look outside of the Xamarin.Forms MVVM functionality in order to write view models that are useful for all your apps. That’s where something like MvvmCross comes into play. MvvmCross is an MVVM framework that is designed to be as cross-platform as possible. With support for Xamarin and Windows platforms, MvvmCross provides a lot of reusability for your view model layer.

Unfortunately, it’s not necessarily a straight-forward process to get your Xamarin.Forms app up and running with MvvmCross. There are resources scattered around the web that help, but nothing comprehensive that gets you up and running after starting from scratch. After having to do it several times on my own the hard way, I decided to write down the steps and make a comprehensive guide. As I mentioned, this is not a straight-forward process, which means there are a lot of steps to go from zero to hero with Xamarin.Forms and MvvmCross. I’ve broken the steps into 5 logical parts, with this being the first.

This guide assumes that you will be targeting all of the platforms supported by Xamarin.Forms (Android, iOS, and Windows Phone) and have the proper tools installed (Visual studio 2013 or later and Xamarin). Having multiple projects in the solution is unavoidable, so most of the steps will call out which project it is targeted for.

There are two important things to be aware of before starting to follow this guide. The first thing is that the guide works for both portable class libraries (PCLs) and universal shared projects. Many of the examples you will find online for working with Xamarin.Forms or MvvmCross will use PCLs and that may be the way to go for your application as well. However, there is one big gotcha that you may end up finding out the hard way: PCLs only let you reference other PCLs. That means you may run into problems as you start to bring in your favorite libraries because they may not be compiled as PCLs. Two notable libraries I’ve found in the apps I’ve written that don’t support PCL are CSLA and Azure Mobile Services (particularly the Microsoft.WindowsAzure.Mobile.Ext assembly that adds the nice UI integration). So, if you plan to go the PCL route, do a little research before you begin to make sure you won’t run into any issues with libraries you plan to use. No such limitation exists for universal shared projects.

The next big gotcha to be aware of before beginning with this guide will become obvious when you start to include your view model layer in other apps, such as Universal Windows apps. While the view model layer is able to be shared, the view layer is not (because it’s built with Xamarin.Forms). The way I deal with this is to put the view models and shared code into one project, which contains no references to Xamarin.Forms. Then I put the views and Xamarin.Forms-specific code into another project, adding a reference to the view model project. You can then reference the view model project in your other non-Xamarin.Forms projects.

This guide will contain a lot of code samples necessary to thread the application foundation together. You can see working app samples for both portable class library and shared project references are out on github:https://github.com/brentedwards/XFormsCrossTemplate.

Let’s begin.