How to bind a ContextAction in a Xamarin Forms ListView to a View Model? This is a question I was asked recently. I created a simple code sample for this, so thought I’d share it with everyone.
Below is a link to the sample on GitHub. It includes an example of how to do it in code and in XAML.
.NET core is really easy to get up and running. Download the installer relevant to your environment from https://www.microsoft.com/net/download/core An IDE such as Visual Studio is optional. I’m going to start with the command line version as it’s really quick to get running. It also doesn’t need much resources for a development environment, which is great as I’m currently using a Samsung Tablet with 2 Gig of RAM to write this blog post.
There is a “Current” and a “LTS” version. Choose which version suites your support needs. “LTS” versions are supported for 3 years. “Current” is the latest version, and is supported for 3 months. I’m going to use “Current” here as it contains all the new juicy bits.
.NET Core Installer
The installer will take a minute or two to run. Once installed, the executable “dotnet” will be added to the path. Also different version of .NET will be installed side by side.
C:\blog\dotnet
Microsoft .NET Core Shared Framework Host
Version : 1.1.0
Build : 928f77c4bc3f49d892459992fb6e1d5542cb5e86
Usage: dotnet [common-options] [[options] path-to-application]
Common Options:
--help Display .NET Core Shared Framework Host help.
--version Display .NET Core Shared Framework Host version.
Options:
--fx-version <version> Version of the installed Shared Framework to use to run the application.
--additionalprobingpath <path> Path containing probing policy and assemblies to probe for.
Path to Application:
The path to a .NET Core managed application, dll or exe file to execute.
If you are debugging the Shared Framework Host, set 'COREHOST_TRACE' to '1' in your environment.
To get started on developing applications for .NET Core, install the SDK from:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
C:\blog\
To create a new app, there’s a “new” command. On first execution it will extract and expand, which may take a moment.
Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include commandline arguments. The data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
Configuring...
-------------------
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.
Decompressing 100% 2294 ms
Expanding 100% 4502 ms
By default, the “dotnet new” command will create a console app. Issuing a “dotnet restore” command, all required packages will be fetched.
C:\blog\dotnet run
Project blog (.NETCoreApp,Version=v1.1) will be compiled because expected outputs are missing
Compiling blog for .NETCoreApp,Version=v1.1
Compilation succeeded.
0 Warning(s)
0 Error(s)
Time elapsed 00:00:00.6861620
Hello World!
C:\blog\
There are various project types: console, web, lib and xunittest. The type can be specified with the -t parameter. The language can be specified with the -l parameter. The available languages are C# and F#
To create a ASP .NET Core / web app, type: “dotnet new -t web”
C:\blog\web>dotnet new -t web
Created new C# project in C:\blog\web.
C:\blog\web>dir
Volume in drive C has no label.
Volume Serial Number is 4A07-921B
Directory of C:\blog\web
02/14/2017 03:12 PM <DIR> .
02/14/2017 03:12 PM <DIR> ..
11/11/2016 12:10 AM 36 .bowerrc
11/11/2016 12:10 AM 3,889 .gitignore
11/11/2016 12:10 AM 265 appsettings.json
11/11/2016 12:10 AM 214 bower.json
02/14/2017 03:12 PM <DIR> Controllers
02/14/2017 03:12 PM <DIR> Data
11/11/2016 12:10 AM 1,193 gulpfile.js
02/14/2017 03:12 PM <DIR> Models
11/11/2016 12:10 AM 239 package.json
11/11/2016 12:10 AM 574 Program.cs
11/11/2016 12:10 AM 3,397 project.json
11/11/2016 12:10 AM 2,229 README.md
02/14/2017 03:12 PM <DIR> Services
11/11/2016 12:10 AM 3,193 Startup.cs
02/14/2017 03:12 PM <DIR> Views
11/11/2016 12:10 AM 563 web.config
02/14/2017 03:12 PM <DIR> wwwroot
11 File(s) 15,792 bytes
8 Dir(s) 92,065,746,944 bytes free
C:\blog\web>
Running the web application is simple: the “dotnet run” command will make this happen. It will even host it in web container.
C:\blog\web>dotnet run
Project web (.NETCoreApp,Version=v1.1) will be compiled because expected outputs are missing
Compiling web for .NETCoreApp,Version=v1.1
C:\blog\web\project.json(5,30): warning NU1007: Dependency specified was Microsoft.NETCore.App >= 1.1.0-preview1-001153-00 but ended up with Microsoft.NETCore.App 1.1.0.
Compilation succeeded.
1 Warning(s)
0 Error(s)
Time elapsed 00:00:01.3100351
info: Microsoft.Extensions.DependencyInjection.DataProtectionServices[0]
User profile is available. Using 'C:\Users\apead\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
Hosting environment: Production
Content root path: C:\blog\web
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
ASP .NET core landing page
Browsing to the URL presented: “http://localhost:5000” will display the ASP .NET core default landing page. This page is also quite useful as it contains links to various learning resources.
.NET core development can be done using any text editor, or in the cross platform lightweight editor Visual Studio Code, or if you prefer the full featured IDE Visual Studio.
This week was brilliant! Scott Hanselman was in South Africa, there was a Microsoft Tech Summit in Johannesburg and then Scott Hanselman was again at DeveloperUG! I extended my stay to attend that, and it was certainly worth it!
There are three Xamarin User Groups in South Africa. Here you will find monthly topics which will include both .NET and Xamarin mobile related topics.
The groups are there to bring the Xamarin community together, where knowledge can be shared and experiences learnt from. Hope you see you at an event soon!
Calling everyone interested in cross platform mobile development. Specifically if you are interested in or using Xamarin tools. Or if you just want to talk mobile development …
Calling everyone interested in cross platform mobile development. Specifically if you are interested in or using Xamarin tools. Or if you just want to talk mobile development …
Xamarin Dev Days South Africa was amazing! Thank you very much to all that attended and hope it was worthwhile to take time off your busy scheduled to learn about Xamarin.
I am so proud to have been part of this and thank you to the team and all involved!
I’m very excited to be able to tell you we are brining Xamarin Dev Days to South Africa for the first time! It will also be held in two cities, Cape Town and Johannesburg.
We have our venues and sponsors organized, and more importantly the dates.
Please diarise!
Xamarin Dev Days Cape Town will be held on the 30th of September 2016. It will be held at Workshop 17 at the V&A.
Xamarin Dev Days Johannesburg will be held on the 23rd of September 2016. It will be held at the Microsoft Bryanston offices.