namespace XFEExtension.NetCore.WinUIHelper.Utilities.Additions; /// /// Provides attached properties for associating navigation targets and parameters with NavigationViewItem controls. /// /// Use the attached properties defined by this class to specify navigation destinations and parameters /// for individual NavigationViewItem instances in a NavigationView. These properties enable declarative navigation /// configuration in XAML or code-behind, allowing navigation logic to retrieve target information and parameters when a /// navigation item is invoked. public class NavigationAddition { /// /// Retrieves the navigation target associated with the specified navigation view item. /// /// The navigation view item from which to obtain the navigation target. Cannot be null. /// A string representing the navigation target for the specified item, or null if no target is set. public static string GetNavigateTo(NavigationViewItem item) => (string)item.GetValue(NavigateToProperty); /// /// Sets the navigation target value for the specified NavigationViewItem. /// /// Use this method to attach a navigation target to a NavigationViewItem, enabling navigation /// logic to identify the destination when the item is selected. /// The NavigationViewItem to associate with the navigation target value. Cannot be null. /// The navigation target value to assign. This value typically represents a page key or URI used for navigation. public static void SetNavigateTo(NavigationViewItem item, string value) => item.SetValue(NavigateToProperty, value); /// /// Identifies the NavigateTo attached property, which specifies the navigation target as a URI or page name for /// supported UI elements. /// /// This dependency property can be set on UI elements to enable navigation behavior, typically /// in frameworks such as WPF or UWP. The value should be a valid URI or page identifier recognized by the /// navigation system. The default value is an empty string. public static readonly DependencyProperty NavigateToProperty = DependencyProperty.RegisterAttached("NavigateTo", typeof(string), typeof(NavigationAddition), new PropertyMetadata("")); /// /// Retrieves the navigation parameter associated with the specified NavigationViewItem. /// /// The NavigationViewItem from which to obtain the navigation parameter. Cannot be null. /// An object representing the navigation parameter for the specified item, or null if no parameter is set. public static object GetNavigateParameter(NavigationViewItem item) => item.GetValue(NavigateParameterProperty); /// /// Sets the navigation parameter value for the specified NavigationViewItem. /// /// Use this method to attach contextual data to a NavigationViewItem, which can be accessed /// during navigation events. This is useful for passing parameters between navigation targets in a /// NavigationView. /// The NavigationViewItem for which to set the navigation parameter. Cannot be null. /// The value to associate with the navigation parameter. This value will be stored and can be retrieved when /// navigating. public static void SetNavigateParameter(NavigationViewItem item, object value) => item.SetValue(NavigateParameterProperty, value); /// /// Identifies the NavigateParameter attached dependency property, which enables passing a navigation parameter to a /// target element in XAML. /// /// This property is typically used in navigation scenarios to associate additional data with a /// UI element when initiating navigation. The value can be any object and is intended to be retrieved by navigation /// logic or handlers. This property is commonly set in XAML using property element syntax. public static readonly DependencyProperty NavigateParameterProperty = DependencyProperty.RegisterAttached("NavigateParameter", typeof(object), typeof(NavigationAddition), new PropertyMetadata(null)); }