优化更新代码,添加界面功能并整合
This commit is contained in:
32
WPFluent/Extensions/FrameExtensions.cs
Normal file
32
WPFluent/Extensions/FrameExtensions.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
|
||||
|
||||
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; }
|
||||
}
|
||||
Reference in New Issue
Block a user