首页 > 解决方案 > 在 Xamarin 的 xmlns 中找不到类型 Ellipse

问题描述

在我的 Xamarin 应用程序中,我试图Ellipse在 xml 中使用,但它返回了错误:

在 xmlns 中找不到类型 Ellipsehttp://xamarin.com/schemas/2014/forms

文档:https ://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/shapes/ellipse

页面.xml

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage 
    xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="Osma.Mobile.App.Views.Start" >

    <ContentPage.Content>
        <StackLayout>

            <Ellipse Fill="Red"
                WidthRequest="150"
                HeightRequest="50"
                HorizontalOptions="Start" />

        </StackLayout>
    </ContentPage.Content>
</ContentPage>

标签: c#.netxamlxamarinxamarin.forms

解决方案


您必须在 App.cs 文件中设置标志

public App() 
{ 
     Device.SetFlags(new[] {"Shapes_Experimental", "Brush_Experimental"}); 
     InitializeComponent() 
} 

推荐阅读