XAML의 기본 제공 모양
.NET프로그래밍/Silverlight 3.0 2009. 11. 24. 18:47 |
[MainPage.xaml]
<UserControl x:Class="RiaXAML.MainPage"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<Button Content="클릭" Foreground="Red" Height="23" HorizontalAlignment="Left" Margin="169,174,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
<TextBlock Height="23" HorizontalAlignment="Left" Margin="140,85,0,0" Name="textBlock1" Text="" VerticalAlignment="Top" Width="120" />
</Grid>
</UserControl>
-------------------------------------------------------------------------------------
[MainPage.xaml.cs]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace RiaXAML
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
// XAML의 모든 요소들은 .NET 명령어로 접근 가능
textBlock1.Width = 300;
textBlock1.Height = 100;
textBlock1.FontSize = 35;
textBlock1.Foreground = new SolidColorBrush(Colors.Red);
textBlock1.Text = DateTime.Now.ToShortTimeString();
}
}
}
-------------------------------------------------------------------------------------
[실행결과]
** 참고 **
--> 아래 그림과 같이 "새 항목 추가"로 "Silverlight User Control"형식인 "*.xaml파일"(여기서는 SubPage.xaml 임.)을 새로 추가할 수 있다.
'.NET프로그래밍 > Silverlight 3.0' 카테고리의 다른 글
레이아웃 - Grid 컨트롤 (0) | 2009.11.24 |
---|---|
레이아웃 - 캔버스 (Canvas) 사용하기 (0) | 2009.11.24 |
XAML(Extensible Application Markup Language)이란? (0) | 2009.11.24 |
Silverlight.js로 XAML 표시 (0) | 2009.11.24 |
<object /> 태그와 <embed />태그로 실버라이트 적용 (0) | 2009.11.24 |