Social Icons

jueves, 4 de agosto de 2022

Aplicación en WPF en C# para mostrar 3 botones

 Archivo XAML:

=======================================================================

<Window x:Class="WpfApp5.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

        xmlns:local="clr-namespace:WpfApp5"

        mc:Ignorable="d"

        Title="MainWindow" Height="450" Width="800">

    <Grid>

        <Button Name="btn1" Background="Pink" 

        BorderBrush="Black" BorderThickness="1"

        Click="OnClick1" ClickMode="Hover" Width="100" Height="100">

            ClickMe1

        </Button>


        <Button Name="btn2" Background="LightBlue" 

        BorderBrush="Black" BorderThickness="1" 

        Click="OnClick2" ClickMode="Press" Width="100" Height="100" Margin="209,167,491,167">

            ClickMe2

        </Button>


        <Button Name="btn3" 

        Click="OnClick3" ClickMode="Release" Width="100" Height="100" Margin="512,167,188,167">

            Reset

        </Button>


    </Grid>

</Window>

=====================================================================
Archivo MainWindow.xaml

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp5
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();


        }

        void OnClick1(object sender, RoutedEventArgs e)
        {
            btn1.Background = Brushes.LightBlue;
        }
        void OnClick2(object sender, RoutedEventArgs e)
        {
            btn2.Background = Brushes.Pink;
        }

        void OnClick3(object sender, RoutedEventArgs e)
        {
            btn1.Background = Brushes.Pink;
            btn2.Background = Brushes.LightBlue;
        }

    }
}

No hay comentarios.:

Publicar un comentario

error code SELF_SIGNED_CERT_IN_CHAIN

Si sale este error se pueda aplicar esta solución: Resuelto: certificado autofirmado en la cadena de certificados - Esri Community https://c...

 
 
Blogger Templates