C#/WPF

[WPF] 화면 중앙에 출력하기, content 에 맞춰 화면 크기 조정하기

kjun.kr 2020. 7. 9. 14:16
728x90

- 화면 중앙에 출력하기

 

WindowStartupLocation="CenterScreen"

 

- content 에 맞춰 화면 크기 조정하기

 

SizeToContent="WidthAndHeight"

 

 

 

<Window x:Class="WpfApp2.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

        xmlns:src="clr-namespace:WpfApp"

        mc:Ignorable="d"

        WindowStartupLocation="CenterScreen"

        SizeToContent="WidthAndHeight"

        Title="MainWindow" Height="400" Width="600">

    <DockPanel>

    </DockPanel>

</Window>

 

 

 

 

728x90