mirror of
https://github.com/PacktPublishing/Learn-WinUI-3-Second-Edition.git
synced 2026-06-20 12:23:09 +00:00
60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.UI.Xaml;
|
|
using Microsoft.UI.Xaml.Controls;
|
|
using Microsoft.UI.Xaml.Navigation;
|
|
using MyMediaCollection.ViewModels;
|
|
|
|
namespace MyMediaCollection.Views
|
|
{
|
|
/// <summary>
|
|
/// An empty page that can be used on its own or navigated to within a Frame.
|
|
/// </summary>
|
|
public sealed partial class ItemDetailsPage : Page
|
|
{
|
|
public ItemDetailsPage()
|
|
{
|
|
ViewModel = App.HostContainer.Services.GetService<ItemDetailsViewModel>();
|
|
|
|
this.InitializeComponent();
|
|
Loaded += ItemDetailsPage_Loaded;
|
|
|
|
Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
|
|
|
|
// Load the user setting
|
|
string haveExplainedSaveSetting = localSettings.Values[nameof(SavingTip)] as string;
|
|
|
|
// If the user has not seen the save tip, display it
|
|
|
|
if (!bool.TryParse(haveExplainedSaveSetting, out bool result) || !result)
|
|
{
|
|
SavingTip.IsOpen = true;
|
|
|
|
// Save the teaching tip setting
|
|
localSettings.Values[nameof(SavingTip)] = "true";
|
|
}
|
|
}
|
|
|
|
private void ItemDetailsPage_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
var mainWindow = (Application.Current as App)?.Window as MainWindow;
|
|
if (mainWindow != null)
|
|
{
|
|
mainWindow.SetPageTitle("Item Details");
|
|
}
|
|
}
|
|
|
|
public ItemDetailsViewModel ViewModel;
|
|
|
|
protected override void OnNavigatedTo(NavigationEventArgs e)
|
|
{
|
|
base.OnNavigatedTo(e);
|
|
|
|
var itemId = (int)e.Parameter;
|
|
|
|
if (itemId > 0)
|
|
{
|
|
ViewModel.InitializeItemDetailData(itemId);
|
|
}
|
|
}
|
|
}
|
|
} |