【发布时间】:2019-03-25 10:15:23
【问题描述】:
我不断收到此错误:
Xamarin.Forms.Xaml.XamlParseException: Position 10:18. StaticResource not found for key TwoButtonTopBarTemplate.
我正在尝试使用我在此页面上制作的模板,当我以相同的方式操作时,它可以在不同的页面上工作。
<?xml version="1.0" encoding="utf-8" ?>
<likeit:InformationPage
xmlns:likeit="clr-namespace:LikeIT"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:devsdna="clr-namespace:DevsDNA;assembly=DevsDNA.GradientBoxView"
x:Class="LikeIT.News">
<ContentView x:Name="newsContentView"
ControlTemplate="{StaticResource TwoButtonTopBarTemplate}" HeightRequest="100">
<StackLayout Spacing="3">
...
</StackLayout>
</ContentView>
</likeit:InformationPage>
当然,我在我的 .cs 文件中使用它。
public partial class News : InformationPage
我的 TwoButtonTopBarTemplate 是在 App 中定义的
<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:abstractions="clr-namespace:RoundedBoxView.Forms.Plugin.Abstractions;assembly=RoundedBoxView.Forms.Plugin.Abstractions"
xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin"
x:Class="LikeIT.forms.App">
<Application.Resources>
<ResourceDictionary>
<ControlTemplate x:Key="TwoButtonTopBarTemplate">
...
</ControlTemplate>
</ResourceDictionary>
</Application.Resources>
</Application>
提前谢谢你。
【问题讨论】:
-
您的模板是在哪里定义的?你也可以分享它的代码吗?
-
你在哪里定义
TwoButtonTopBarTemplate -
我添加了它,@G.hakim
-
由于您没有添加任何实际代码,没有这些代码我们就会瘫痪,我建议您阅读此docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/…
-
我确实添加了代码...?
标签: c# android visual-studio xamarin xamarin.forms