在我的Xamarin Forms應用程序中,我試圖在我的一個xaml文件中設置嵌入式圖像的來源,但創建自定義名稱空間時,出現錯誤 Xamarin.Forms.Xaml.XamlParseException: Position 31:12. MarkupExtension not found for local:ImageResource
。我基於https://developer.xamarin.com/guides/xamarin-forms/working-with/images/#Embedded_Images的官方文檔,並且還檢查了示例代碼。我的程序集名稱和默認名稱空間都與xaml文件中的匹配。未找到Xaml標記擴展
我在Windows上使用Visual Studio 2015。我有其他人在Mac上試用Xamarin Studio上的代碼,代碼工作正常,圖像顯示。
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:local="clr-namespace:App;assembly=App"
x:Class="App.LoginPage">
<RelativeLayout>
<Label Text="Logo"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.3}" BackgroundColor="Aqua" />
<StackLayout Spacing="20" Padding="20"
VerticalOptions="Center"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.5}"
RelativeLayout.XConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}"
RelativeLayout.YConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.3}">
<Entry Placeholder="Username"
Text="{Binding Username}"/>
<Entry Placeholder="Password"
Text="{Binding Password}"
IsPassword="true"/>
<Button Text="Login" TextColor="White"
BackgroundColor="Blue"
Command="{Binding LoginCommand}"/>
</StackLayout>
<Image Source="{local:ImageResource App.logo.png}"
Aspect="AspectFill"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.4}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.15}"
RelativeLayout.XConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.6}"
RelativeLayout.YConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.85}" />
</RelativeLayout>
</ContentPage>
誰能幫助?
當您構建或運行您的項目時是否出現此錯誤? – user1