Prism Library Quick Tip – Snippets

Pieter van der Westhuizen, a professional freelance web & mobile developer and founder of Coalition Software.
Search for a command to run...

Pieter van der Westhuizen, a professional freelance web & mobile developer and founder of Coalition Software.
A recent requirement came up for configurable dynamic forms in a mobile application. There are a few dynamic form packages for Flutter, but I wanted a bit more control over the schema and behavior of the form. Here follows my attempt at creating dyna...

If you've ever written a mobile app with Flutter that integrates with an API, then you'll know that there are a lot of model objects that get passed between the app and the API. JSON Serialization in Flutter can also take a fair amount of boilerplate...

Back in May 2020, Microsoft announced a new feature for Azure Blob Storage called Blob Index. Essentially, this enables you to add key/value tags to your Blob objects and be able to query said Blob objects without having to use a separate service lik...

In my last post, "Using AWS Cognito with Xamarin Forms", I showed how to authenticate with Amazon Cognito using Xamarin Forms and the Xamarin.Essentials Web Authenticator. In this post, we'll go through the process of using the AWS Cognito Hosted UI ...

In this post, I'll show you how to quickly and easily set up user authentication for your Xamarin Forms app using Amazon Cognito. AWS Cognito is a user identity management solution by Amazon. It is a really easy way to add authentication to your appl...

The Prism Template pack, available on Visual Studio Marketplace, offers a collection of helpful snippets to speed up your development. To use the snippets in Visual Studio, simply type the shortcut (e.g. propp) and press TAB.
Here is a quick list of each as a handy reference:
Generate a property with a backing field, that depends on BindableBase. This means it will generate a standard property, but with a setter that uses the BindableBase SetProperty method, e.g.
private string fieldName;
public string PropertyName
{
get { return fieldName; }
set { SetProperty(ref fieldName, value); }
}
Generates a DelegateCommand property, with backing field and the associated Execute method, e.g.
private DelegateCommand _fieldName;
public DelegateCommand CommandName =>
_fieldName ?? (_fieldName = new DelegateCommand(ExecuteCommandName));
void ExecuteCommandName()
{
}
Generate a DelegateCommand property, with backing field as well as its associated Execute method. It also creates the CanExecute method for you, e.g.
private DelegateCommand _fieldName;
public DelegateCommand CommandName =>
_fieldName ?? (_fieldName = new DelegateCommand(ExecuteCommandName, CanExecuteCommandName));
void ExecuteCommandName()
{
}
bool CanExecuteCommandName()
{
return true;
}
Similar to the cmd snippet mentioned above, but this one generates a generic DelegateCommand property
private DelegateCommand<string> _fieldName;
public DelegateCommand<string> CommandName =>
_fieldName ?? (_fieldName = new DelegateCommand<string>(ExecuteCommandName));
void ExecuteCommandName(string parameter)
{
}
Similar to the cmdfull snippet mentioned above, but this one generates a generic DelegateCommand property with its associated Execute and CanExecute Methods
private DelegateCommand<string> _fieldName;
public DelegateCommand<string> CommandName =>
_fieldName ?? (_fieldName = new DelegateCommand<string>(ExecuteCommandName, CanExecuteCommandName));
void ExecuteCommandName(string parameter)
{
}
bool CanExecuteCommandName(string parameter)
{
return true;
}
These snippets are incredibly handy when working with Prism as it really makes it easy to add the code elements essential for the framework to work smoothly.
To read more about the Prism Library, visit [http://prismlibrary.com/](http://prismlibrary.com/ "http://prismlibrary.com/")
Thank you for reading. Until next time, keep coding!