33 lines
924 B
C#
33 lines
924 B
C#
|
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
namespace WPFluent.Extensions;
|
|
|
|
/// <summary>
|
|
/// Set of extensions for <see cref="System.Windows.Controls.Frame"/>.
|
|
/// </summary>
|
|
public static class FrameExtensions
|
|
{
|
|
/// <summary>
|
|
/// Cleans <see cref="Frame"/> journal.
|
|
/// </summary>
|
|
/// <param name="frame">Selected frame.</param>
|
|
public static void CleanNavigation(this Frame frame)
|
|
{
|
|
while(frame.CanGoBack)
|
|
{
|
|
frame.RemoveBackEntry();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets <see cref="FrameworkElement.DataContext"/> from <see cref="Frame"/>.
|
|
/// </summary>
|
|
/// <param name="frame">Selected frame.</param>
|
|
/// <returns>DataContext of currently active element, otherwise <see langword="null"/>.</returns>
|
|
public static object? GetDataContext(this Frame frame)
|
|
{ return frame.Content is not FrameworkElement element ? null : element.DataContext; }
|
|
}
|