NavigationPage + CarouselView。错误:无法激活实例

时间:2019-03-19 15:36:55

标签: c#

我使用了MasterDetailPage。并使用NavigationPage导航。 在添加项目CarouselView之前,这个简单的好工作。

public List<MasterPageItem> menuList { get; set; }
        public MainPage()
        {
            InitializeComponent();

            menuList = new List<MasterPageItem>();
            menuList.Add(new MasterPageItem() { Title = "Главная", Icon = "home.png", TagetType = typeof(HomePage) });
            menuList.Add(new MasterPageItem() { Title = "Расписание", Icon = "calendar.png", TagetType = typeof(DiaryPage) });
            menuList.Add(new MasterPageItem() { Title = "Новости", Icon = "news.png", TagetType = typeof(NewsPage) });
            menuList.Add(new MasterPageItem() { Title = "Профиль", Icon = "profile.png", TagetType = typeof(ProfilePage) });

            navigationDrawerList.ItemsSource = menuList;
            Detail = new NavigationPage((Page)Activator.CreateInstance(typeof(TestPage)));

        }

        private void onMenuItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var item = (MasterPageItem)e.SelectedItem;            
            Type page = item.TagetType;
            Detail = new NavigationPage((Page)Activator.CreateInstance(page));            
            IsPresented = false;

        }

如果打开的页面包含CarouselView和属性VerticalOptions =“ FillAndExpand”,则显示异常

System.NotSupportedException: Unable to activate instance of type Com.ViewPagerIndicator.CirclePageIndicator 

来自本机句柄0x7fc5472274(key_handle 0x584e8e5)。

xaml文件

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:carousel="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"   
             x:Class="AppMobile.Views.HomePage"
             Title="Home">
    <ContentPage.Content>
        <StackLayout>
            <StackLayout HeightRequest="300">
                <carousel:CarouselViewControl x:Name="MyCV" BackgroundColor="Green" VerticalOptions="FillAndExpand" >
                    <!--ShowIndicators="True" -->
                    <carousel:CarouselViewControl.ItemTemplate>
                        <DataTemplate>
                            <StackLayout BackgroundColor="Blue">
                                <Image x:Name="myImg" Source="{Binding FileName}"  Aspect="AspectFill" />
                            </StackLayout>
                        </DataTemplate>
                    </carousel:CarouselViewControl.ItemTemplate>
                </carousel:CarouselViewControl>
            </StackLayout>      
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

如果排除属性VerticalOptions =“ FillAndExpand”,则CarouselViewControl中的内容为空。为什么要同时使用两个组件而没有错误?

0 个答案:

没有答案