Skip to content

Instantly share code, notes, and snippets.

View ayeshnipun's full-sized avatar
☠️
Beware

Ayesh Nipun ayeshnipun

☠️
Beware
View GitHub Profile
<Button Text="Click Me" Command="{Binding ShowMessageCommand}" />
public class CommandViewModel
{
public ICommand ShowMessageCommand { get; }
public CommandViewModel()
{
ShowMessageCommand = new Command(() =>
{
Application.Current.MainPage.DisplayAlert("Hello", "Command executed!", "OK");
});
<Label Text="{Binding ProductName, Mode=OneTime}" FontSize="18"/>
<Label Text="{Binding Name, Mode=TwoWay}" FontSize="24"/>
<Label Text="{Binding Name, Mode=OneWay}" FontSize="24"/>
<Label Text="Status" TextColor="{Binding IsActive, Converter={StaticResource BoolToColorConverter}}"/>
public class BoolToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? Colors.Green : Colors.Red;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyApp.MainPage">
<ContentPage.BindingContext>
<local:UserViewModel />
</ContentPage.BindingContext>
<StackLayout Padding="20">
<Label Text="{Binding Name}" FontSize="24"/>
<Entry Text="{Binding Name, Mode=TwoWay}" Placeholder="Enter your name"/>
public class UserViewModel : INotifyPropertyChanged
{
private string name;
public string Name
{
get => name;
set
{
if (name != value)
{
@ayeshnipun
ayeshnipun / Dockerfile
Created June 19, 2022 12:01
Dockerfile
#Stage 1
FROM node:17-alpine as builder
WORKDIR /app
COPY package*.json .
COPY yarn*.lock .
RUN yarn install
COPY . .
RUN yarn build
#Stage 2