У меня есть страница PopUp , к которой я перехожу. У меня проблема в том, что при отладке код никогда не выполняет конструктор. У меня есть другие страницы в этом приложении, которые все работают нормально, а также другая всплывающая страница, на которой просто отлично работает конструктор.
Я использую Prism Mvvm для местоположения ViewModel
. Я дважды проверил правильность всех пространств имен, все из которых вы увидите ниже. Если кто-то сталкивался с этим раньше, пожалуйста, помогите мне выйти из этого. Представление также зарегистрировано в моем App.xaml.cs
для Навигация
Представление
<popup:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:popup="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns:templates="clr-namespace:MyApp.Views.Templates;assembly=MyApp"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
mc:Ignorable="d"
x:Class="MyApp.Views.UserProfileView">
<ScrollView VerticalOptions="Center">
<Frame Margin="15"
BackgroundColor="White">
<StackLayout IsClippedToBounds="True"
Padding="10, 5"
Spacing="3">
<Label Text="Test"/>
<Button Text="Go Back" Command="{Binding GoBackCommand}"/>
</StackLayout>
</Frame>
</ScrollView>
</popup:PopupPage>
ViewModel
namespace MyApp.ViewModels
{
public class UserProfileView : BaseViewModel
{
private INavigationService _navigationService;
public DelegateCommand GoBackCommand { get; }
public UserProfileView(INavigationService navigationService)
{
_navigationService = navigationService;
GoBackCommand = new DelegateCommand(async () => await _navigationService.GoBackAsync());
}
}
Как я перейти на страницувыше
private async void NavigateToUserProfileView()
{
await _navigationService.NavigateAsync("UserProfileView");
}