XF 按钮控件

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:App19"
             x:Class="App19.MainPage">
    <StackLayout VerticalOptions="Center">
    <Button BorderColor="Black" Text="点击我" BorderWidth="2" BorderRadius="10" Clicked="Button_Clicked"></Button>
    </StackLayout>

</ContentPage>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace App19
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void Button_Clicked(object sender, EventArgs e)
        {
            ((Button)sender).BackgroundColor = Color.Red;
        }
    }
}
 

原文地址:https://www.cnblogs.com/dxmfans/p/9434581.html