Частичные виды Autowire Injection не работает Prism - PullRequest
0 голосов
/ 05 марта 2020

Я использую Prism Через свое приложение, и я создал панель пользовательских представлений, и хочу внедрить службу навигации везде, где я назвал эту панель инструментов. Я нахожу только один пример, который со мной не работал.

Просмотр содержимого

<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             xmlns:prism="clr-namespace:Prism.Ioc;assembly=Prism.Forms"
             xmlns:mvvm="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
             x:Name="AppToolbarview" 
             xmlns:local="clr-namespace:IFind.Views"
             BackgroundColor="#20019C"
             x:Class="IFind.Views.AppToolbar">
    <local:AppToolbar mvvm:ViewModelLocator.AutowirePartialView="{x:Reference AppToolbarview}" />
    <ContentView.Content>
            <ImageButton x:Name="backbtn" Grid.Row="0" HorizontalOptions="Start" HeightRequest="30" WidthRequest="25" VerticalOptions="CenterAndExpand" BackgroundColor="Transparent" Grid.Column="0" Source="back.png" Command="{Binding BackCommand}"  Aspect="AspectFit"></ImageButton>
    </ContentView.Content>
</ContentView>

Просмотр модели

public class AppToolbarViewModel : BindableBase
{
    private INavigationService _navigationService;

    public DelegateCommand BackCommand => new DelegateCommand(Back);

    private void Back()
    {
        _navigationService.GoBackAsync();
    }

    public AppToolbarViewModel(INavigationService navigationService)
    {
        _navigationService = navigationService;
    }
}

Я попробовал это, а затем попытался Зарегистрировать службу вручную в app.cs

   ViewModelLocationProvider.Register<AppToolbar,AppToolbarViewModel>();

, но приложение зависало на странице, которая содержит Apptoolbar

    Native Crash Reporting
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

No native Android stacktrace (see debuggerd output).

=================================================================
    Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0xcd19c3ca):0xcd19c3ba  c0 5e 5f 

Любая помощь? большое спасибо

...