Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed the access modifier of the AutowireViewModel method to public #2557

Merged
merged 3 commits into from
Sep 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/Wpf/Prism.Wpf/Common/MvvmHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Prism.Mvvm;
#if HAS_UWP
Expand All @@ -18,15 +19,35 @@ namespace Prism.Common
public static class MvvmHelpers
{
#if HAS_UWP || HAS_WINUI
internal static void AutowireViewModel(object viewOrViewModel)
/// <summary>
/// Sets the AutoWireViewModel property to true for the <paramref name="viewOrViewModel"/>.
/// </summary>
/// <remarks>
/// The AutoWireViewModel property will only be set to true if the view
/// is a <see cref="FrameworkElement"/>, the DataContext of the view is null, and
/// the AutoWireViewModel property of the view is null.
/// </remarks>
/// <param name="viewOrViewModel">The View or ViewModel.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public static void AutowireViewModel(object viewOrViewModel)
{
if (viewOrViewModel is FrameworkElement view && view.DataContext is null && ViewModelLocator.GetAutowireViewModel(view) is null)
{
ViewModelLocator.SetAutowireViewModel(view, true);
}
}
#else
internal static void AutowireViewModel(object viewOrViewModel)
/// <summary>
/// Sets the AutoWireViewModel property to true for the <paramref name="viewOrViewModel"/>.
/// </summary>
/// <remarks>
/// The AutoWireViewModel property will only be set to true if the view
/// is a <see cref="FrameworkElement"/>, the DataContext of the view is null, and
/// the AutoWireViewModel property of the view is null.
/// </remarks>
/// <param name="viewOrViewModel">The View or ViewModel.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public static void AutowireViewModel(object viewOrViewModel)
{
if (viewOrViewModel is FrameworkElement view && view.DataContext is null && ViewModelLocator.GetAutoWireViewModel(view) is null)
{
Expand Down