=====================XAML Layout code=========================================
=====================Background code========================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace App2.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Page1 : ContentPage
{
public Page1()
{
InitializeComponent();
BindingContext = new MyViewModel();
}
}
internal class MyViewModel: INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
Xamarin.Forms.Color mButtBckColor1 = Xamarin.Forms.Color.White;
public Xamarin.Forms.Color MButtBckColor1
{
get { return mButtBckColor1; }
set
{
mButtBckColor1 = value;
OnPropertyChanged(nameof(MButtBckColor1));
}
}
int mId1=1001;
public int MId1
{
set
{
mId1 = value;
OnPropertyChanged(nameof(MId1));
}
get { return mId1; }
}
string mText1;
private int idValue;
public string MText1
{
set {
mText1=value;
OnPropertyChanged(nameof(MText1) );
}
get { return mText1; }
}
public ICommand RestCommand { private set; get; }
public ICommand ChangeColorMCommand { private set; get; }
public MyViewModel()
{
MText1 = "Color Test";
MButtBckColor1 = Xamarin.Forms.Color.DarkCyan;
RestCommand = new Command(() => ResetCellsData());
ChangeColorMCommand = new Command((o) => ChangeClickEvne(o));
}
private void ChangeClickEvne(object sender)
{
var firstBUtton = sender as Button;
var id=firstBUtton.ClassId;
MButtBckColor1 = Xamarin.Forms.Color.Red;
}
private void ResetCellsData()
{
MButtBckColor1 = Xamarin.Forms.Color.DarkCyan;
MText1 = "123";
}
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
==================================Here is style in App.xaml==================================================