해결되었습니다
xaml에서 새로운 루트요소를 추가 or 루트요소 설정법을 찾고 있습니다.
페이지로 생성한 xaml의 루트 요소를
Page에서 BasePage(클래스 파일)로 변경했습니다.
디버깅시 BasePage의 형식을 찾을 수 없다고 나옵니다.
<!-- LoginPage.xaml -->
<Page x:Class="Fasetto.word.Framework.LoginPage"
...
</Page>
<!-- Page를 BasePage로 변경 -->
<local:BasePage x:Class="Fasetto.word.Framework.LoginPage"
...
</local:BasePage>
페이지를 생성후 Ex) LoginPage.xaml
기본 루트 요소를 Page => BasePage로 변경 했습니다.
// LoginPage.cs
public partial class LoginPage : Page
{
public LoginPage()
{
InitializeComponent();
}
}
=> public partial class LoginPage : BasePage //상속 부분을 BasePage 로 변경
Page에서 받던 상속을 BasePage로 해주었구요.
<!-- BasePage.cs -->
public class BasePage : Page
{
#region Public Properties
/// <summary>
/// The animation the play when the page is first loded
/// </summary>
public PageAnimation PageLoadAnimation { get; set; } = PageAnimation.SlideAndFadeInFromRight;
/// <summary>
/// The animation the play when the page is unloded
/// </summary>
public PageAnimation PageUnloadAnimation { get; set; } = PageAnimation.SlideAndFadeOutToLeft;
/// <summary>
/// The time any slide animation takes to complete
/// </summary>
public float SlideSeconds { get; set; } = 0.8f;
#endregion
#region Constructor
/// <summary>
/// Default constructor
/// </summary>
public BasePage()
{
// If we are animation in, hide to begin with
if (this.PageLoadAnimation != PageAnimation.None)
this.Visibility = Visibility.Collapsed;
// Listen out for the page loading
this.Loaded += BasePage_Loaded;
}
#endregion
#region Animation Load / Unload
/// <summary>
/// Once the page is loaded, perform any required animation
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <exception cref="NotImplementedException"></exception>
private void BasePage_Loaded(object sender, RoutedEventArgs e)
{
AnimateIn();
}
/// <summary>
/// Animates in this page
/// </summary>
/// <returns></returns>
public async Task AnimateIn()
{
// Make sure we have something th do
if (this.PageLoadAnimation != PageAnimation.None)
return;
switch (this.PageLoadAnimation)
{
case PageAnimation.SlideAndFadeInFromRight:
var sb = new Storyboard();
var slideAnimation = new ThicknessAnimation
{
Duration = new Duration(TimeSpan.FromSeconds(this.SlideSeconds)),
From = new Thickness(this.WindowWidth, 0, -this.WindowWidth, 0),
To = new Thickness(0),
DecelerationRatio = 0.9f
};
Storyboard.SetTargetProperty(slideAnimation, new PropertyPath("Margin"));
sb.Children.Add(slideAnimation);
sb.Begin(this);
this.Visibility = Visibility.Visible;
await Task.Delay((int)(this.SlideSeconds * 1000));
break;
}
}
#endregion
클래스로 생성한 BasePage.cs입니다.
우선 Page에서 받던 상속을 BasePage로 변경 했을 때부터 오류가 납니다.
(페이지’의 부분 선언은 다른 기본 클래스를 지정할 수 없습니다.)
LoginPage.g.i.cs로 가보니 ( public partial class LoginPage에서 LoginPage 코드 정의로 가기)
'System.Windows.Controls.Page’로 상속 설정된 부분을
프로젝트 네임스페이스.BasePage로 변경했습니다.
다음
<! -- LoginPage.xaml -->
xmlns:local="clr-namespace:Fasetto.word.Framework"
"xmlns:local…"를 추가 후 루트요소를 찾을 수 있습니다.
현재하고 있는 부분이 Page폴더에 BasePage.cs, LoginPage.xaml, Animation폴더의 PageAnimation.cs 입니다.
저장소 : 프로젝트파일