【发布时间】:2020-03-19 22:25:33
【问题描述】:
我有一个写标题的 xaml 文件。
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="TeenageClubWallet.Templates.Header">
<StackLayout>
<Label Text="Header!" />
</StackLayout>
我想将此 xaml 文件用作其他 xaml 文件中的标头。 这是一个例子。我正在尝试将其包含到另一个 xaml 文件中:
我添加了一个命名空间:xmlns:template="clr-namespace:TeenageClubWallet.Templates"
“模板”标签现在用于包含文件:
<?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:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="TeenageClubWallet.Statistics"
xmlns:template="clr-namespace:TeenageClubWallet.Templates">
<ContentPage.Content>
<template:Header/>
<StackLayout>
<Label Text="Content!" />
</StackLayout>
</ContentPage.Content>
Visual Studio 显示错误:“错误 XLS0501 属性 'Content' 设置了多次。”
如何将一个 xaml 文件中的内容包含到另一个 xaml 文件中?
【问题讨论】:
标签: xaml xamarin xamarin.forms