<Window x:Class="WpfApplication4.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Button Name="btn1" Background="Pink"
BorderBrush="Black" BorderThickness="1"
Click="OnClick1" ClickMode="Hover">
ClickMe1
</Button>
<Button Name="btn2" Background="LightBlue"
BorderBrush="Black" BorderThickness="1"
Click="OnClick2" ClickMode="Press">
ClickMe2
</Button>
<Button Name="btn3"
Click="OnClick3" ClickMode="Release">
Reset
</Button>
</Grid>
</Window>
--------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 WpfApplication4
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
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;
}
}
}
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Button Name="btn1" Background="Pink"
BorderBrush="Black" BorderThickness="1"
Click="OnClick1" ClickMode="Hover">
ClickMe1
</Button>
<Button Name="btn2" Background="LightBlue"
BorderBrush="Black" BorderThickness="1"
Click="OnClick2" ClickMode="Press">
ClickMe2
</Button>
<Button Name="btn3"
Click="OnClick3" ClickMode="Release">
Reset
</Button>
</Grid>
</Window>
--------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 WpfApplication4
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
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 comments:
Post a Comment