728x90
그림 1. Border 프로그램
<Window x:Class="wpf19.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="450" Width="600">
<Grid>
<Border Name="root" BorderThickness="2" BorderBrush="Black"
Background="LightGray" Width="350" Height="350">
<Canvas>
<Button Name="btn" Canvas.Top="40" Canvas.Left="40"
Background="LightSkyBlue" Height="35"
Click="ChangeBackground_Click"
Content="Click Me to change the Background Color" />
<TextBlock Canvas.Top="130" Canvas.Left="40" Name="Text1"
Text="Waiting for Click!"/>
</Canvas>
</Border>
</Grid>
</Window>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="450" Width="600">
<Grid>
<Border Name="root" BorderThickness="2" BorderBrush="Black"
Background="LightGray" Width="350" Height="350">
<Canvas>
<Button Name="btn" Canvas.Top="40" Canvas.Left="40"
Background="LightSkyBlue" Height="35"
Click="ChangeBackground_Click"
Content="Click Me to change the Background Color" />
<TextBlock Canvas.Top="130" Canvas.Left="40" Name="Text1"
Text="Waiting for Click!"/>
</Canvas>
</Border>
</Grid>
</Window>
BorderThickness : Border 두께
BorderBrush : Border 색깔
Borderground : Border 배경색
using System;
using System.Collections;
using System.Collections.Generic;
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.Shapes;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
namespace wpf19
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
void ChangeBackground_Click(object sender, RoutedEventArgs e)
{
root.Background = Brushes.LightSteelBlue;
btn.Content = "Clicked";
Text1.Text = "The Blackground is now LightSteelBlue";
}
}
}
using System.Collections;
using System.Collections.Generic;
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.Shapes;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
namespace wpf19
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
void ChangeBackground_Click(object sender, RoutedEventArgs e)
{
root.Background = Brushes.LightSteelBlue;
btn.Content = "Clicked";
Text1.Text = "The Blackground is now LightSteelBlue";
}
}
}
ChangeBackground_Click 이벤트가 발생되면 Border의 색깔을 LightSteelBlue로 변경하고 Button의 이름은 “Clicked!“, 로 TextBox의 내용은 "The background is now LightSteelBlue“으로 각각 변경이 됩니다.
※ 테스트 환경
-----------------------------------------------------------------------------------------
운영체체 : Windows Vista Ultimate 32bit
개발툴 : Microsoft Visual C# Codename "Orcas"
-----------------------------------------------------------------------------------------
'.NET WPF' 카테고리의 다른 글
[Controls] 22. Element:Shape (Polyline/Polygon) (0) | 2007.01.31 |
---|---|
[Controls] 21. Element:Shape (Line:선) (0) | 2007.01.30 |
[Controls] 20. Element:Shape (Ellipse:원) (0) | 2007.01.28 |
[Controls] 16. Expender (0) | 2007.01.12 |
[Controls] 15. Treeview (0) | 2007.01.11 |
[Controls] 14. Slider Style DataBinding (0) | 2007.01.10 |
[Controls] 13. Menu (0) | 2006.12.22 |
댓글