mirror of
https://github.com/AlexMacocian/Net.Maui.Extensions.git
synced 2026-07-15 14:59:31 +00:00
BindingContext extension for viewmodels
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using Net.Maui.Extensions.ControlFlow;
|
||||
using System.ComponentModel;
|
||||
using System.Core.Extensions;
|
||||
using System.Extensions;
|
||||
|
||||
@@ -6,9 +7,9 @@ namespace Net.Maui.Extensions.Extensions;
|
||||
|
||||
public static class ContentPageExtensions
|
||||
{
|
||||
public static T GetBindingContext<T>(this ContentPage contentPage)
|
||||
where T : INotifyPropertyChanged
|
||||
public static T? GetBindingContext<T>(this IPageViewModel<T> page)
|
||||
where T : class, INotifyPropertyChanged, new()
|
||||
{
|
||||
return contentPage.ThrowIfNull().BindingContext.Cast<T>();
|
||||
return page.As<BindableObject>()?.ThrowIfNull()?.BindingContext.As<T>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>true</IsPackable>
|
||||
<Version>0.2.10</Version>
|
||||
<Version>0.2.11</Version>
|
||||
<Authors>Alexandru Macocian</Authors>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
|
||||
Reference in New Issue
Block a user