35 lines
759 B
C#
35 lines
759 B
C#
using System;
|
|
using System.Windows.Controls;
|
|
using ExcelHelper.Views;
|
|
|
|
namespace ExcelHelper.Services;
|
|
|
|
public class NavigationService
|
|
{
|
|
private Frame _frame;
|
|
public static string currentView;
|
|
|
|
public void InitForFrame(Frame frame)
|
|
{
|
|
_frame = frame;
|
|
}
|
|
public void NavigateTo<T>()
|
|
{
|
|
var target = App.AppHost.Get<T>();
|
|
if (target is IView page)
|
|
{
|
|
currentView = typeof(T).Name;
|
|
_frame.NavigationService.Navigate(page);
|
|
}
|
|
}
|
|
public void NavigateTo(Type type)
|
|
{
|
|
var target = App.AppHost.Get(type);
|
|
if (target is IView page)
|
|
{
|
|
currentView = type.Name;
|
|
_frame.NavigationService.Navigate(page);
|
|
}
|
|
}
|
|
}
|