Xamarin 相同的listview 2不同的页面
我想在两个不同的页面上使用相同的listview我该怎么做。所以我想在两个不同的页面上显示相同的listviewXamarin 相同的listview 2不同的页面,xamarin,xamarin.forms,xamarin.android,xamarin.ios,xamarin-studio,Xamarin,Xamarin.forms,Xamarin.android,Xamarin.ios,Xamarin Studio,我想在两个不同的页面上使用相同的listview我该怎么做。所以我想在两个不同的页面上显示相同的listview <?xml version="1.0" encoding="UTF-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/
<?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:vm="clr-namespace:Tobacco.ViewModels"
x:Class="Tobacco.Views.NewItemPage"
Shell.PresentationMode="ModalAnimated"
Title="New Item">
<ContentPage.BindingContext>
<vm:AboutViewModel />
</ContentPage.BindingContext>
<ContentPage.Resources>
<ResourceDictionary>
<Color x:Key="Accent">#0c7b93</Color>
</ResourceDictionary>
</ContentPage.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackLayout BackgroundColor="{StaticResource Accent}" VerticalOptions="FillAndExpand" HorizontalOptions="Fill">
<StackLayout Orientation="Horizontal" HorizontalOptions="Center" VerticalOptions="Center">
<ContentView Padding="0,40,0,40" VerticalOptions="FillAndExpand">
<Image Source="add_product.png" VerticalOptions="Center" HeightRequest="64" />
</ContentView>
</StackLayout>
</StackLayout>
<ScrollView Grid.Row="1">
<StackLayout Orientation="Vertical" Padding="30,90,30,24" Spacing="7">
<Entry Placeholder="Ürün Kodu" FontSize="16" x:Name="txtProductCode" Keyboard="Numeric"/>
<Entry Placeholder="Marka" FontSize="16" x:Name="txtProductBrand"/>
<Entry Placeholder="Ürün" FontSize="16" x:Name="txtProductName"/>
<Entry Placeholder="Fiyat" FontSize="16" x:Name="txtProductPrice"/>
<Button Margin="0,15,0,0" Text="Ürün Ekle"
BackgroundColor="{StaticResource Primary}"
TextColor="White" x:Name="addProduct" Clicked="addProduct_Clicked"/>
<ContentView>
<ListView x:Name="lstProducts">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell Text="{Binding ProductName}" Detail="{Binding ProductPrice}"></TextCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentView>
</StackLayout>
</ScrollView>
</Grid>
</ContentPage>
#0c7b93
要么复制粘贴,要么将ListView封装在ContentView中,并在两个页面上引用它。复制粘贴无法解决此问题。你能不能简单地解释一下,我还是新手。如果你想得到更多帮助,你需要发布你的代码。请不要将代码或错误作为图像发布如果将ListView的XAML复制到新页面上的XAML,会发生什么?这实际上是共享代码的最简单方式。不幸的是,这也没有发生。让我解释如下:我有两个xaml页面,一个将注册产品,另一个将在listview中显示这些记录。我希望它变得更容易理解。非常感谢你的帮助。