지금 예제는Command Bindings 와 CommandExecute 와 CommandExecute 를 간단하게 사용해보자.~

Command를사용하는 이유?

http://msdn.microsoft.com/ko-kr/library/ms752308(v=VS.90).aspx

명령의 정의


WPF의 명령 시스템은 RoutedCommandRoutedEvent를 기반으로 합니다. 명령은 반드시 RoutedCommand일 필요가 없으며 단순히 ICommand를 구현할 수도 있지만 이 개요에서는 주로 RoutedCommand 모델에 중점을 두어 설명합니다.

명령은 작업의 의미 체계 및 출처를 해당 논리와 구분한다는 점에서 단추에 연결된 간단한 이벤트 처리기와 다릅니다. 이와 같은 특징 때문에 서로 다른 여러 소스가 동일한 명령 논리를 호출할 수 있으며 명령 논리를 여러 대상에 대해 사용자 지정할 수 있습니다.

이러한 명령의 예로 여러 응용 프로그램에서 볼 수 있는 복사, 잘라내기, 붙여넣기 등의 편집 작업이 있습니다. 명령의 의미 체계는 응용 프로그램과 클래스 전체에서 일관되지만 작업 논리는 작업 대상 개체마다 다릅니다. Ctrl+X 키 조합은 텍스트 클래스, 이미지 클래스 및 웹 브라우저에서 잘라내기 명령을 호출하지만 잘라내기 작업을 수행하는 실제 논리는 명령을 호출한 소스가 아니라 잘라내기가 발생하는 개체 또는 응용 프로그램에 따라 정의됩니다. 예를 들어 텍스트 개체는 선택한 텍스트를 잘라내서 클립보드에 복사하는 반면 이미지 개체는 선택한 이미지를 잘라내지만 두 클래스 모두에서 동일한 명령 소스인 KeyGesture 또는 ToolBar 단추를 사용하여 명령을 호출할 수 있습니다.

 

실행된 모습

image

100미만 일때 버튼 비활성화

image

 

XAML

    <Grid>
        <Button Content="Button" Margin="192,146,163,93" Name="Btn" />
        <TextBox Height="40" HorizontalAlignment="Left" Margin="192,100,0,0" Name="textBox1" VerticalAlignment="Top" Width="148" Text="100" FontSize="28" />
        <Label Content="입력값이 100 이상일때만 아래버튼 활성화" Height="43" HorizontalAlignment="Left" Margin="12,28,0,0" Name="label1" VerticalAlignment="Top" FontSize="24" />
    </Grid>

 

Cs

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 WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public static RoutedCommand MyCommand = new RoutedCommand();


        public MainWindow()
        {
            InitializeComponent();
            CommandBinding cb = new CommandBinding(MyCommand,
       MyCommandExecute, MyCommandCanExecute);

            this.CommandBindings.Add(cb);
            this.Btn.Command = MyCommand; //버튼에다가 커멘트 연결중…
        }
//CommandCanExecute요기서  CommandExecute 를 실행할수 있는지 검사 ㅋ
        private void MyCommandCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(this.textBox1.Text))
            {
                if (int.Parse(this.textBox1.Text) >= 100)
                {
                    e.CanExecute = true;
                }
                else
                {
                    e.CanExecute = false;
                }
            }
            else {
                e.CanExecute = false;
            }
        }

        private void MyCommandExecute(object sender, ExecutedRoutedEventArgs e)
        {
            MessageBox.Show("My Command!");
         
        }
    }
}

프로젝트 구성

image

실제 필요한 파일은 ClosableTab.cs / CloseableHeader.xaml 가 전부 입니다.

ClosableTab.cs은 TabItem  상속받는다 클래스를 만든다.

전체소스는 아래쪽에..~

image

[실제 바인딩 된 모습]

image  image image

 

Header 만들기

CloseableHeader.xaml 이 파일은  상단의 탭헤더가 될것입니다.

image

 

ClosableTab 에서 보면 헤더를  CloseableHeader.xaml 파일로 지정합니다.

image

CloseableHeader.xaml  소스

<UserControl x:Class="RibbonWpfApplication.CloseableHeader"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        
        <Button Content="X"  Height="19" HorizontalAlignment="Right" Margin="0,3,4,0" Name="button_close" VerticalAlignment="Top" Width="20" FontFamily="Courier" FontWeight="Bold" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" FontStretch="Normal" Visibility="Visible" FontSize="14" Padding="0" ToolTip="Close"/>
        <Label Content="TabItem"  Height="23" HorizontalAlignment="Left" Margin="4,1,0,0" Name="label_TabTitle" VerticalAlignment="Top" FontFamily="Courier" FontSize="12" />
    </Grid>
</UserControl>

image

클릭했을때 탭컨트롤 추가하기

ClosableTab theTabItem = new ClosableTab();
theTabItem.Title = "Small title";
MainTabControl.Items.Add(theTabItem);
theTabItem.Focus();

 

ClosableTab.cs  Full 소스

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace RibbonWpfApplication
{
    class ClosableTab : TabItem
    {


        // Constructor
        public ClosableTab()
        {
            // 아까만들었던던 CloseableHeader.xaml을 이용해서 헤더를 붙입니다.
            CloseableHeader closableTabHeader = new CloseableHeader();

            // Assign the usercontrol to the tab header
            this.Header = closableTabHeader;

            // Attach to the CloseableHeader events (Mouse Enter/Leave, Button Click, and Label resize)
            closableTabHeader.button_close.MouseEnter += new MouseEventHandler(button_close_MouseEnter);
            closableTabHeader.button_close.MouseLeave += new MouseEventHandler(button_close_MouseLeave);
            closableTabHeader.button_close.Click += new RoutedEventHandler(button_close_Click);
            closableTabHeader.label_TabTitle.SizeChanged += new SizeChangedEventHandler(label_TabTitle_SizeChanged);
        }



        /// <summary>
        /// Property - Set the Title of the Tab
        /// </summary>
        public string Title
        {
            set
            {
                ((CloseableHeader)this.Header).label_TabTitle.Content = value;
            }
        }
        

        //
        // - - - Overrides  - - -
        //

        // Override OnSelected - Show the Close Button
        protected override void OnSelected(RoutedEventArgs e)
        {
            base.OnSelected(e);
            ((CloseableHeader)this.Header).button_close.Visibility = Visibility.Visible;
        }

        // Override OnUnSelected - Hide the Close Button
        protected override void OnUnselected(RoutedEventArgs e)
        {
            base.OnUnselected(e);
            ((CloseableHeader)this.Header).button_close.Visibility = Visibility.Hidden;
        }

        // Override OnMouseEnter - Show the Close Button
        protected override void OnMouseEnter(MouseEventArgs e)
        {
            base.OnMouseEnter(e);
            ((CloseableHeader)this.Header).button_close.Visibility = Visibility.Visible;
        }

        // Override OnMouseLeave - Hide the Close Button (If it is NOT selected)
        protected override void OnMouseLeave(MouseEventArgs e)
        {
            base.OnMouseLeave(e);
            if (!this.IsSelected)
            {
                ((CloseableHeader)this.Header).button_close.Visibility = Visibility.Hidden;
            }
        }
        


        //
        // - - - Event Handlers  - - -
        //


        // Button MouseEnter - When the mouse is over the button - change color to Red
        void button_close_MouseEnter(object sender, MouseEventArgs e)
        {
            ((CloseableHeader)this.Header).button_close.Foreground = Brushes.Red;
        }

        // Button MouseLeave - When mouse is no longer over button - change color back to black
        void button_close_MouseLeave(object sender, MouseEventArgs e)
        {
            ((CloseableHeader)this.Header).button_close.Foreground = Brushes.Black;
        }


        // Button Close Click - Remove the Tab - (or raise an event indicating a "CloseTab" event has occurred)
        void button_close_Click(object sender, RoutedEventArgs e)
        {
            ((TabControl)this.Parent).Items.Remove(this);
        }


        // Label SizeChanged - When the Size of the Label changes (due to setting the Title) set position of button properly
        void label_TabTitle_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            ((CloseableHeader)this.Header).button_close.Margin = new Thickness(((CloseableHeader)this.Header).label_TabTitle.ActualWidth + 5, 3, 4, 0);
        }





    }
}

완료된 모습

(아래의 x 표를 클릭하면 탭을 제거할수 있습니다)

image

더 자세한 설명:

http://www.codeproject.com/KB/WPF/WpfTabCloseButton.aspx

아래의 다운로드의 파일은 XP에서 오류가 발생합니다

정식릴리즈 받으세요
http://kojaedoo.tistory.com/532

간단하게 구현중인모습

 

이벤트를 걸기위한 이벤트 Resources

    <Window.Resources>        
        <ResourceDictionary>
            <my:RibbonCommand x:Key="CopyCommand" 
			LabelTitle="Copy" LabelDescription="복사를 진행합니다." LargeImageSource="/RibbonWpfApplication;component/Images/7.jpg" Executed="RibbonCommand_Executed"></my:RibbonCommand>
        </ResourceDictionary>
    </Window.Resources>

Executed="RibbonCommand_Executed" 비하인드 코드에서 처리

        private void RibbonCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            MessageBox.Show("RibbonCommand_Executed");
        }

ribbon 메뉴구현

       <my:Ribbon  Title="" DockPanel.Dock="Top"  x:Name="RibbonWindow">
            	<my:Ribbon.BindingGroup>
            		<BindingGroup/>
            	</my:Ribbon.BindingGroup>    		
    		
    			<my:Ribbon.ApplicationMenu>
    				<my:RibbonApplicationMenu />
    			</my:Ribbon.ApplicationMenu>
                
                
    			<my:RibbonTab Label="Personnel" d:IsLocked="True">
    				<my:RibbonGroup>
                        <my:RibbonButton Command="{StaticResource CopyCommand}" />                                        
                    </my:RibbonGroup>
    				
    			</my:RibbonTab>
					<my:RibbonTab Label="메뉴2">
						<my:RibbonGroup>
                        <my:RibbonButton Content="메뉴2 서브메뉴" />
                    </my:RibbonGroup>
					</my:RibbonTab>
                <my:RibbonTab Label="메뉴3"/>
                <my:RibbonTab Label="메뉴4"/>
                <my:RibbonTab Label="메뉴5"/>
                <my:RibbonTab Label="메뉴6"/>
                <my:RibbonTab Label="메뉴7"/>
                <my:RibbonTab Label="메뉴8"/>
                <my:RibbonTab Label="메뉴9"/>
    		</my:Ribbon>

코드상에서 이벤트걸기

<my:RibbonButton Command="{StaticResource CopyCommand}" />

 

ApplicationMenu 드롭다운 메뉴 구현하기

 
이벤트 거는것은 위에와 같고

<my:Ribbon.ApplicationMenu>
    <my:RibbonApplicationMenu>
        <my:RibbonApplicationMenuItem Command="{StaticResource FileCommand}"/>
        </my:RibbonApplicationMenu>
</my:Ribbon.ApplicationMenu>

블랜드에서는 ..

위의 코드와 같은 역활을 한다

image

http://wpf.codeplex.com/wikipage?title=WPF%20Ribbon%20Preview

WPF Ribbon Preview

NOTE: The content posted here about the WPF Ribbon is provided as a convenience for developers using the WPF Toolkit who may also be interested in the WPF Ribbon. The WPF Ribbon preview is available for download on the Office UI Licensing site (a link to the site can be found towards the bottom of this page) and is NOT available for download from Codeplex.
You can download a preview version of the WPF Ribbon from the Office UI Licensing Site
  1. Follow the link above and click on "License the Office UI"
  2. Login using your Windows Live ID. If you don't have a Windows Live ID already, you can create one for free
  3. Read and accept the Office UI License
    1. Licensing the Office UI (including the Ribbon) is free. You must accept the license in order to access the WPF Ribbon download
  4. Click on the WPF Ribbon download button
  5. Accept the WPF Ribbon CTP License and follow the instructions to download the Ribbon binaries
  6. Click on the buttons for "2007 Microsoft Office Fluent UI Design Guidelines License" and "Microsoft Fluent Third Party Usage Guidelines" to download the Office UI Licensing Guidelines

http://msdn.microsoft.com/ko-kr/office/aa973809.aspx 가서
라이센스 동의하고 컨트롤 받으면됩니다.

참고 다운로드

What Others Are Downloading

Others who downloaded 2007 Office System Document: User Interface License and Program Frequently Asked Questions also downloaded:

  1. 2007 Office System Add-In: Icons Gallery
  2. Windows Ribbon: Introductory Tutorial
  3. Windows Ribbon: Samples
  4. 2007 Office System Document: UI Style Guide for Solutions and Add Ins
  5. Microsoft Windows SDK for Windows 7 and .NET Framework 4

 

image

 

image

Dll의 기능을 Tool Box에 넣어주면 됩니다.

image

생성된 모습

 

Blend 에서는 Locations 가보면 RibbonControlsLibray.dll 이 있다

이걸로 조지면 됨

image

테스트삼아

image

아래는 실행된 모습
image

메뉴하나를 끌어왔다.

참고로 리본을 클릭 후 속성을 보면 나름 컨트롤 할수 있게 해두었다
image

아래 이미지를 보면 어떤 메뉴인지 대충 감은 올꺼임다.

MS 사에서 제공하는 리본메뉴 설명

image

http://msdn.microsoft.com/en-us/library/cc872782.aspx

일단 스토리보드 만들고 시작 ㅋ

image

아래와 같은 스토리보드를 하나 만들어준다 BUTTON 을 클릭하면
스토리가 움직이게 할꺼다

image

image 

 

image

무비제작 완료했으면
image 이버튼에 아래와 같이 이름을 준다.
(이버튼을 클릭하면 무비시작)

image

트리거 탭을 보면 아래와 같이 화면이 로드될떄 바로 시작하게 되있다

image

이것을 버튼클릭시 움직이게 만들꺼다

우선 버튼을 클릭해서 개체를 선택한 다음에

image

+Event를 눌러준다.

image

아래 When 에서 BtnMovieStart 버튼을 선택해주면된다.

그런다음 클릭할때 움직일꺼니깐 Click 선택해주고

image

그다음 왼쪽에 + 버튼을 눌러서 Click했을때 움직일 스토리 보드를 추가해준다

image

이걸로 끗`

실행된모습

image

 

시작(프로젝트 만들기)~

image
Person.cs는 바인딩할 리스트를반환한다.

바인딩용 리스트 만들기

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace TestWpfApplication
{


    public class Person
    {

        public Person()
        {

        }

        public Person(string name, int age)
        {
            this.Name = name;
            this.Age = age;
        }

        public string Name
        {
            set;
            get;
        }

        public int Age
        {
            set;
            get;
        }

        public static List<Person> GetPerson()
        {
            List<Person> p = new List<Person>();
            p.Add(new Person("kojaedoo", 19));
            p.Add(new Person("kojaeasdfdoo", 29));
            p.Add(new Person("1kafojaedoo", 13));
            p.Add(new Person("kojaasdfedoo", 49));
            p.Add(new Person("kojaedadfoo", 15));
            p.Add(new Person("kojaaaeadfdoo", 39));
            p.Add(new Person("kojafasdfedoo", 49));
            p.Add(new Person("kojaedofffo", 89));
            p.Add(new Person("kojaedo1234o", 79));
            return p;
        }
    }
}

GetPerson() 으로 리스트를 돌려받을꺼임

바인딩 처리

MainWindow.xaml
리스트박스에 ItemsSource를 ItemsSource=”{Binding}” 이라고 지정한다.

image

그럼 Blend에서 보면

image

이렇게 바인딩된 표시로 나타난다.

이제 아이템리스트 템플릿을  지정!

image

리스트박스에 마우스 오른쪽을 대고 Edit Generated Items를 클릭한다.

image

클릭하면

image

이런창이 나타난다 확인 누르고 계속 ㄱㄱ

코드상으로 템플릿이 추가되었다

image

코드도 ItemTemplate 를 사용하게 변경되어져 있다.

image

위와같이 추가되어져 있다.

ItemTemplate변경하기

위에서 확인 눌러도 암것도 없다

여기에 출력할 Name과 Age를 표시해주자

image

TextBlock을 끌어와서 대충디쟌
image

요렇게 앞에는 Name 뒤에는 Age 표시할꺼다

텍스트블록을 클릭한다음

image

Text의 바인딩을 지정해주자

 

image 
Data Context로 맞춘다음

image
Name이라고 지정해따 Age도 똑같이 ㄱㄱ

 

비하인드 코드에서 바인딩해주기

image

F5

image

ItemsPanelTemplate을 변경하면

image
아래와 같이 가로로도 출력되게 할수 있다 ㅋ

image

 

private void TextBlock_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
{
    Storyboard myStoryboard;   
    myStoryboard = (Storyboard)this.Resources["Storyboard1"];   
    myStoryboard.Begin(this);   
}

ToolBar

image

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <ToolBar HorizontalAlignment="Center" VerticalAlignment="Center">
        <Button>1</Button>
        <Button>2</Button>
    </ToolBar>
</Grid>

ScrollViewer

image

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <ScrollViewer >         
    <StackPanel VerticalAlignment="Top" HorizontalAlignment="Left">
        <TextBlock TextWrapping="Wrap" Margin="0,0,0,20">Scrolling is
        enabled when it is necessary.</TextBlock>
        <Rectangle Fill="Red" Width="400" Height="800"></Rectangle>
    </StackPanel>
</ScrollViewer>
</Grid>

FlowDocumentPageViewer

image

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<FlowDocumentPageViewer>         
<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Paragraph Style="{StaticResource HeaderStyle}">Canvas Overview</Paragraph>
    <Paragraph><Rectangle Fill="Black" Height="1" Width="500" HorizontalAlignment="Left" /><LineBreak/></Paragraph>
    <Paragraph Style="{StaticResource DisStyle}">[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]<LineBreak/></Paragraph>
<Paragraph Style="{StaticResource mainContentStyle}">The Canvas element is used to position content according to absolute x- and y-coordinates. Canvas provides ultimate flexibility for positioning and arranging elements on the screen. Elements can be drawn in a unique location, or in the event that elements occupy the same coordinates, the order in which they appear in markup determines the order in which elements are drawn.</Paragraph>

<Paragraph Style="{StaticResource mainContentStyle}">This topic contains the following sections.</Paragraph>

<List>

<ListItem><Paragraph Style="{StaticResource mainContentStyle}">What Can I Do with the Canvas?</Paragraph></ListItem>
<ListItem><Paragraph Style="{StaticResource mainContentStyle}">Adding a Border to a Canvas Element</Paragraph></ListItem>
<ListItem><Paragraph Style="{StaticResource mainContentStyle}">Order of Elements in a Canvas</Paragraph></ListItem>
<ListItem><Paragraph Style="{StaticResource mainContentStyle}">Creating a Canvas in "XAML"</Paragraph></ListItem>
<ListItem><Paragraph Style="{StaticResource mainContentStyle}">Creating a Canvas in Code</Paragraph></ListItem>

</List>
    <Paragraph Style="{StaticResource SubHeaderStyle}">What Can I Do with the Canvas?</Paragraph>
    <Paragraph Style="{StaticResource mainContentStyle}">Canvas provides the most flexible layout support of any Panel element. Height and Width properties are used to define the area of the canvas, and elements inside are assigned absolute coordinates relative to the upper left corner of the parent Canvas. This allows you to position and arrange elements precisely where you want them on the screen.</Paragraph>

<Paragraph Style="{StaticResource SubHeaderStyle}">Adding a Border to a Canvas Element</Paragraph>
<Paragraph Style="{StaticResource mainContentStyle}">In order for a Canvas element to have a border, it must be encapsulated within a Border element.</Paragraph>
</FlowDocument>
</FlowDocumentPageViewer>
</Grid>

TabControl

image

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <TabControl HorizontalAlignment="Center" VerticalAlignment="Center">
    <TabItem Header="Background" IsSelected="true"><Button Name="btn" Background="LightGray">Background</Button>
    </TabItem>
    <TabItem Header="Foreground"><Button Name="btn1" Foreground="Black">Foreground</Button>
    </TabItem>
    <TabItem Header="FontFamily"><Button Name="btn2" FontFamily="Arial">FontFamily</Button></TabItem>
    <TabItem Header="FontSize"><Button Name="btn3" FontSize="10">FontSize</Button></TabItem>
    <TabItem Header="FontStyle"><Button Name="btn4" FontStyle="Normal">FontStyle</Button></TabItem>
    <TabItem Header="FontWeight"><Button Name="btn5" FontWeight="Normal">FontWeight</Button></TabItem>
    <TabItem Header="BorderBrush"><Button Name="btn6" BorderBrush="Red">BorderBrush</Button></TabItem>
</TabControl>
</Grid>

InkCanvas

image

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <InkCanvas EditingMode="Ink" MaxWidth="300" MaxHeight="300">
                <TextBlock>Use your Mouse or Stylus to draw on the screen.</TextBlock>
            </InkCanvas>
</Grid>

Menu

image

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<Menu Background="Gray" HorizontalAlignment="Center" VerticalAlignment="Center">
   <MenuItem Header="File">
          <MenuItem Header="New"/>
          <MenuItem Header="Open"/>
	        <Separator/>
          <MenuItem Header="submenu">
                <MenuItem Header="submenuitem1"/>
                <MenuItem Header="submenuitem2">          
                      <MenuItem Header="submenuitem2.1"/>
                </MenuItem>
         </MenuItem>
   </MenuItem>
   <MenuItem Header="View">
       <MenuItem Header="Source"/>
    </MenuItem>   
</Menu>
</Grid>

 

Border

image

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <Border Background="LightGray" CornerRadius="10" Padding="10"  HorizontalAlignment="Center" 
		VerticalAlignment="center" BorderBrush="Black" BorderThickness="4">
        <TextBlock>Content inside of a Border</TextBlock>
    </Border>
</Grid>

 

StackPanel

image

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <StackPanel>
        <Border Background="SkyBlue" BorderBrush="Black" BorderThickness="1">
            <TextBlock Foreground="black" FontSize="12">Stacked Item #1</TextBlock>
        </Border>
        <Border Width="400" Background="CadetBlue" BorderBrush="Black" BorderThickness="1">
            <TextBlock Foreground="black" FontSize="14">Stacked Item #2</TextBlock>
        </Border>
        <Border Background="#ffff99" BorderBrush="Black" BorderThickness="1">
            <TextBlock Foreground="black" FontSize="16">Stacked Item #3</TextBlock>
        </Border>
        <Border Width="200" Background="PaleGreen" BorderBrush="Black" BorderThickness="1">
            <TextBlock Foreground="black" FontSize="18">Stacked Item #4</TextBlock>
        </Border>
        <Border Background="White" BorderBrush="Black" BorderThickness="1">
            <TextBlock Foreground="black" FontSize="20">Stacked Item #5</TextBlock>
        </Border>
    </StackPanel>
</Grid>

 

image

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml
/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <Canvas Margin="10">
        <Canvas Height="100" Width="100"  Top="0" Left="0">
            <Rectangle Width="100" Height="100" Fill="red"/>
        </Canvas>
        <Canvas Height="100" Width="100" Top="100" Left="100">
            <Rectangle Width="100" Height="100" Fill="green"/>
         </Canvas>
         <Canvas Height="100" Width="100" Top="50" Left="50">
            <Rectangle Width="100" Height="100" Fill="blue"/>
         </Canvas>
     </Canvas>
</Grid>

image

<Grid xmlns="http://schemas.microsoft.com/winfx
/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <Viewbox MaxWidth="500" MaxHeight="500" StretchDirection="Both" Stretch="Fill">
            <Grid >
            <Ellipse Fill="#99ccff" Stroke="RoyalBlue" StrokeDashArray="3"  />
            <TextBlock Text="Viewbox" />
            </Grid>
    </Viewbox>
</Grid>

image

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <DockPanel>
        <Border Height="25" Background="SkyBlue" BorderBrush="Black" BorderThickness="1" DockPanel.Dock="Top">
            <TextBlock Foreground="black">Dock = "Top"</TextBlock>
        </Border>
        <Border Height="25" Background="SkyBlue" BorderBrush="Black" BorderThickness="1" DockPanel.Dock="Top">
            <TextBlock Foreground="black">Dock = "Top"</TextBlock>
        </Border>
        <Border Height="25" Background="#ffff99" BorderBrush="Black" BorderThickness="1" DockPanel.Dock="Bottom">
            <TextBlock Foreground="black">Dock = "Bottom"</TextBlock>
        </Border>
        <Border Width="200" Background="PaleGreen" BorderBrush="Black" BorderThickness="1" DockPanel.Dock="Left">
            <TextBlock Foreground="black">Dock = "Left"</TextBlock>
        </Border>
        <Border Background="White" BorderBrush="Black" BorderThickness="1">
            <TextBlock Foreground="black">This content fills the remaining, unallocated space.</TextBlock>
        </Border>
    </DockPanel>
</Grid>

Expander

image

<Expander Header="More Options">
    <StackPanel Margin="10,4,0,0">
        <CheckBox Margin="4" Content="Option 1" />
        <CheckBox Margin="4" Content="Option 2" />
        <CheckBox Margin="4" Content="Option 3" />
    </StackPanel>
</Expander>

스택판넬에 안넣으니깐 기본적으로 벌어져보이네 ㅋ

+ Recent posts