728x90
반응형
728x170
▶ ContentPage.xaml
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="컨텐트 페이지">
<Grid>
<Ellipse
Margin="50"
Fill="RoyalBlue" />
</Grid>
</Page>
728x90
▶ 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="Application 클래스 : GetContentStream 정적 메소드를 사용해 컨텐트 XAML 페이지 로드하기"
FontFamily="나눔고딕코딩"
FontSize="16">
<Frame Name="frame"
Margin="10"
BorderThickness="1"
BorderBrush="Black" />
</Window>
반응형
▶ MainWindow.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using System.Windows.Resources;
namespace TestProject
{
/// <summary>
/// 메인 윈도우
/// </summary>
public partial class MainWindow : Window
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary>
/// 생성자
/// </summary>
public MainWindow()
{
InitializeComponent();
Uri uri = new Uri("/CONTENT/ContentPage.xaml", UriKind.Relative);
//Uri uri = new Uri("pack://application:,,,/TestProject;component/CONTENT/ContentPage.xaml", UriKind.Absolute);
StreamResourceInfo info = Application.GetContentStream(uri);
XamlReader reader = new XamlReader();
Page page = (Page)reader.LoadAsync(info.Stream);
this.frame.Content = page;
}
#endregion
}
}
※ ContentPage.xaml 파일은 [빌드 작업] 항목을 [내용]으로, [출력 디렉터리에 복사] 항목을 [항상 복사] 또는 [새 버전이면 복사]로 설정한다.
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] Page 엘리먼트 : WindowWidth/WindowHeight/WindowTitle 속성 사용하기 (0) | 2022.01.04 |
---|---|
[C#/WPF] Application 클래스 : GetRemoteStream 정적 메소드를 사용해 원본 사이트 파일 XAML 페이지 로드하기 (0) | 2022.01.02 |
[C#/WPF] 원본 사이트 파일 사용하기 (0) | 2022.01.02 |
[C#/WPF] Frame 엘리먼트 : Source 속성을 사용해 컨텐트 XAML 페이지 로드하기 (0) | 2022.01.02 |
[C#/WPF] Frame 클래스 : Source 속성을 사용해 컨텐트 XAML 페이지 로드하기 (0) | 2022.01.02 |
[C#/WPF] Frame 엘리먼트 : Source 속성을 사용해 리소스 XAML 페이지 로드하기 (0) | 2022.01.02 |
[C#/WPF] Frame 클래스 : Source 속성을 사용해 리소스 XAML 페이지 로드하기 (0) | 2022.01.02 |
[C#/WPF] Application 클래스 : GetResourceStream 정적 메소드를 사용해 리소스 XAML 페이지 로드하기 (0) | 2022.01.02 |
[C#/WPF] VirtualizingStackPanel 클래스 : IsVirtualizing/VirtualizationMode 속성을 사용해 대용량 데이터 바인딩하기 (0) | 2021.12.31 |
[C#/WPF] Popup 클래스 : 다른 엘리먼트 위에 엘리먼트를 오버레이 배치하기 (0) | 2021.12.31 |
댓글을 달아 주세요