728x90
반응형
728x170
▶ ResourcePage.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 클래스 : GetResourceStream 정적 메소드를 사용해 리소스 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("/RESOURCE/ResourcePage.xaml", UriKind.Relative);
//Uri uri = new Uri("pack://application:,,,/TestProject;component/RESOURCE/ResourcePage.xaml", UriKind.Absolute);
StreamResourceInfo info = Application.GetResourceStream(uri);
XamlReader reader = new XamlReader();
Page page = (Page)reader.LoadAsync(info.Stream);
this.frame.Content = page;
}
#endregion
}
}
※ ResourcePage.xaml 파일은 [빌드 작업] 항목을 [Resource]로 설정한다.
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] Frame 엘리먼트 : Source 속성을 사용해 컨텐트 XAML 페이지 로드하기 (0) | 2022.01.02 |
---|---|
[C#/WPF] Frame 클래스 : Source 속성을 사용해 컨텐트 XAML 페이지 로드하기 (0) | 2022.01.02 |
[C#/WPF] Application 클래스 : GetContentStream 정적 메소드를 사용해 컨텐트 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] VirtualizingStackPanel 클래스 : IsVirtualizing/VirtualizationMode 속성을 사용해 대용량 데이터 바인딩하기 (0) | 2021.12.31 |
[C#/WPF] Popup 클래스 : 다른 엘리먼트 위에 엘리먼트를 오버레이 배치하기 (0) | 2021.12.31 |
[C#/WPF] HwndHost 클래스 : WPF 윈도우 내부에서 메모장 윈도우 호스팅하기 (0) | 2021.12.31 |
[C#/WPF] 3D 애니메이션 시계 사용하기 (절전 모드 방지 기능 추가) (0) | 2021.11.17 |
[C#/WPF] DataGrid 클래스 : 데이터 업데이트 성능 측정하기 (0) | 2021.10.22 |
댓글을 달아 주세요