[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 임.)을 새로 추가할 수 있다.















 

Posted by holland14
: