반응형
- 프로그램을 작성하여 운용할 때 실행창을 곧바로 최대화해야 할 상황이 올 수 있다.
<MainPage.xaml.cs>
namespace TestProject
{
public sealed partial class MainPage : Page
{
public MainPage()
{
MaximizePageOnLoad();
this.InitializeComponent();
}
void MaximizePageOnLoad()
{
var page = DisplayInformation.GetForCurrentView();
// 화면 해상도를 얻어온다
var page_resolution = new Size(page.ScreenWidthInRawPixels, page.ScreenHeightInRawPixels);
// 유효한 픽셀단위로 화면 크기를 계산한다..
var page_scale = page.ResolutionScale == ResolutionScale.Invalid ? 1 : page.RawPixelsPerViewPixel;
var page_bounds = new Size(page_resolution.Width / page_scale, page_resolution.Height / page_scale);
ApplicationView.PreferredLaunchViewSize = new Size(page_bounds.Width, page_bounds.Height);
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
}
}
}
<MainPage.xaml.cs>
<Page
x:Class="TestProject.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestProject"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.Row="0" Grid.Column="0">
<TextBlock Text="U" FontSize="200" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Row="0" Grid.Column="1">
<TextBlock Text="W" FontSize="200" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Row="0" Grid.Column="2">
<TextBlock Text="P" FontSize="200" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Row="1" Grid.ColumnSpan="3">
<TextBlock Text="Screen" FontSize="200" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Row="2" Grid.Column="0">
<TextBlock Text="MAXI" FontSize="200" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Row="2" Grid.Column="1">
<TextBlock Text="MIZE" FontSize="200" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Row="2" Grid.Column="2">
<TextBlock Text=":D" FontSize="200" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
</Grid>
</Page>
반응형
'프로그래밍 > UWP | WPF' 카테고리의 다른 글
[UWP] ContentDialog 이용하여 Popup Box 만들기 (0) | 2022.08.11 |
---|---|
[UWP] Button pressed 효과 만들기 (0) | 2022.08.11 |
UWP Grid를 이용한 화면 분할 및 Border를 이용한 Grid 연결 (0) | 2022.05.25 |
UWP 프로그램 실행 시에 랜덤 이미지 보여주기 (0) | 2022.05.25 |
UWP 버튼에 마우스 커서 올리면(mouse hover) 안보임 해결방법 (0) | 2022.05.24 |
댓글