// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
namespace WPFluent.Gallery.Controls;
public class GalleryNavigationPresenter : System.Windows.Controls.Control
{
/// Identifies the dependency property.
public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register(
nameof(ItemsSource),
typeof(object),
typeof(GalleryNavigationPresenter),
new PropertyMetadata(null)
);
/// Identifies the dependency property.
public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register(
nameof(TemplateButtonCommand),
typeof(WPFluent.Input.IRelayCommand),
typeof(GalleryNavigationPresenter),
new PropertyMetadata(null)
);
public object? ItemsSource
{
get => GetValue(ItemsSourceProperty);
set => SetValue(ItemsSourceProperty, value);
}
///
/// Gets the command triggered after clicking the titlebar button.
///
public WPFluent.Input.IRelayCommand TemplateButtonCommand =>
(WPFluent.Input.IRelayCommand)GetValue(TemplateButtonCommandProperty);
///
/// Initializes a new instance of the class.
/// Creates a new instance of the class and sets the default event.
///
public GalleryNavigationPresenter()
{
SetValue(TemplateButtonCommandProperty, new Input.RelayCommand(o => OnTemplateButtonClick(o)));
}
private void OnTemplateButtonClick(Type? pageType)
{
INavigationService navigationService = App.GetRequiredService();
if (pageType is not null)
{
_ = navigationService.Navigate(pageType);
}
System.Diagnostics.Debug.WriteLine(
$"INFO | {nameof(GalleryNavigationPresenter)} navigated, ({pageType})",
"WPFluent.Gallery"
);
}
}