728x90
반응형
728x170
■ Image 엘리먼트의 Stretch 속성을 사용하는 방법을 보여준다.
▶ 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
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] 도형 위치/크기 변경하기 (0) | 2020.08.04 |
---|---|
[C#/WPF] 도형 위치/크기 변경하기 (Polygon 제외) (0) | 2020.08.04 |
[C#/WPF] DockPanel 클래스 : LastChildFill 속성 사용하기 (0) | 2020.08.04 |
[C#/WPF] Window 클래스 : WindowStyle 속성 사용하기 (0) | 2020.08.04 |
[C#/WPF] Window 클래스 : ResizeMode 속성 사용하기 (0) | 2020.08.04 |
[C#/WPF] Window 클래스 : SizeToContent 속성 사용하기 (0) | 2020.08.03 |
[C#/WPF] Freezable 클래스 : Freeze 메소드를 사용해 객체 고정하기 (0) | 2020.08.03 |
[C#/WPF] SystemParameters 클래스 : MinimumWindowWidth/MinimumWindowHeight 속성을 사용해 최소 윈도우 크기 구하기 (0) | 2020.08.03 |
[C#/WPF] Application 클래스 : OnSessionEnding 메소드를 사용해 세션 종료시 처리하기 (0) | 2020.08.03 |
[C#/WPF] Application 클래스 : OnStartup 메소드를 사용해 메인 윈도우 표시하기 (0) | 2020.08.03 |
댓글을 달아 주세요