첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ Image 엘리먼트의 Stretch 속성을 사용하는 방법을 보여준다.

TestProject.zip
다운로드

▶ MainWindow.xaml

<Window x:Class="TestProject.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="800"
    Height="600"
    Title="Image 엘리먼트 : Stretch 속성 사용하기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Window.Resources>
        <Style TargetType="{x:Type Rectangle}">
            <Setter Property="HorizontalAlignment" Value="Left"  />
            <Setter Property="VerticalAlignment"   Value="Top"   />
            <Setter Property="Opacity"             Value="0.5"   />
            <Setter Property="Stroke"              Value="Gray"  />
            <Setter Property="StrokeThickness"     Value="2"     />
            <Setter Property="Fill"                Value="White" />
        </Style>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Margin" Value="10" />
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="10" />
            <RowDefinition Height="*"  />
            <RowDefinition Height="10" />
            <RowDefinition Height="*"  />
            <RowDefinition Height="10" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="10" />
            <ColumnDefinition Width="*"  />
            <ColumnDefinition Width="10" />
            <ColumnDefinition Width="*"  />
            <ColumnDefinition Width="10" />
        </Grid.ColumnDefinitions>
        <Image Grid.Row="1" Grid.Column="1"
            Stretch="Fill"
            Source="IMAGE/sample.jpg" />
        <Rectangle Grid.Row="1" Grid.Column="1"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            Stroke="Black"
            StrokeThickness="1"
            Fill="{x:Null}" />
        <Rectangle Grid.Row="1" Grid.Column="1"
            Width="135"
            Height="40" />
        <TextBlock Grid.Row="1" Grid.Column="1"
            Text="Stretch = Fill" />
        <Image Grid.Row="1" Grid.Column="3"
            Stretch="None"
            Source="IMAGE/sample.jpg" />
        <Rectangle Grid.Row="1" Grid.Column="3"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            Stroke="Black"
            StrokeThickness="1"
            Fill="{x:Null}" />
        <Rectangle Grid.Row="1" Grid.Column="3"
            Width="135"
            Height="40" />
        <TextBlock Grid.Row="1" Grid.Column="3"
            Text="Stretch = None" />
        <Image Grid.Row="3" Grid.Column="1"
            Stretch="Uniform"
            Source="IMAGE/sample.jpg" />
        <Rectangle Grid.Row="3" Grid.Column="1"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            Stroke="Black"
            StrokeThickness="1"
            Fill="{x:Null}" />
        <Rectangle Grid.Row="3" Grid.Column="1"
            Width="155"
            Height="40" />
        <TextBlock Grid.Row="3" Grid.Column="1"
            Text="Stretch = Uniform" />
        <Image Grid.Row="3" Grid.Column="3"
            Stretch="UniformToFill"
            Source="IMAGE/sample.jpg" />
        <Rectangle Grid.Row="3" Grid.Column="3"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            Stroke="Black"
            StrokeThickness="1"
            Fill="{x:Null}" />
        <Rectangle Grid.Row="3" Grid.Column="3"
            Width="205"
            Height="40" />
        <TextBlock Grid.Row="3" Grid.Column="3"
            Text="Stretch = UniformToFill" />
    </Grid>
</Window>
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요