小编Mar*_*ark的帖子

ListView 项目内按钮的绑定 (Xamarin)

3天后我一直在尝试所有“可能有你答案的问题”,仍然没有快乐。

我有一个 XAML 页面,其中包含产品及其详细信息的 ListView,使用绑定到名为 RackProducts 的模型,如您所见:

<?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="PapillonWine.PapillonRackCatalogPage" 
             xmlns:local="clr-namespace:PapillonWine;assembly=PapillonWine" 
             xmlns:artina="clr-namespace:UXDivers.Artina.Shared;assembly=UXDivers.Artina.Shared"
             xmlns:customContentView="clr-namespace:PapillonWine.NavBars"
             Title="{ artina:Translate PageTitleProductsCatalog }"
             BackgroundColor="{ DynamicResource MainWrapperBackgroundColor }"
             x:Name="CatalogItemPage">

    <ContentPage.Content>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="70" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <customContentView:CustomNavigationBar Grid.Row="0" x:Name="NavigationBarView" BackgroundColor="Transparent"/>

            <ListView
            x:Name="PapillonRackItems"    
            Grid.Row="1" 
            ItemsSource="{ Binding RackProducts }"
            HasUnevenRows="True"
            ItemSelected="OnItemSelected">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <local:PapillonCatalogItemTemplate />
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </Grid>
    </ContentPage.Content>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)

每个产品都使用 PapillonCatalogItemTemplate 显示,该模板包含四个按钮(查看产品图像轮播、添加到购物车、查看尺寸以及最后共享产品)。这个 PapillonCatalogItemTemplate 如下:

<?xml version="1.0" encoding="utf-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="PapillonWine.PapillonCatalogItemTemplate" 
             xmlns:local="clr-namespace:PapillonWine;assembly=PapillonWine" 
             xmlns:artina="clr-namespace:UXDivers.Artina.Shared;assembly=UXDivers.Artina.Shared"
             xmlns:customContentView="clr-namespace:PapillonWine.NavBars"
             xmlns:ffimageloading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms" 
             xmlns:fftransformations="clr-namespace:FFImageLoading.Transformations;assembly=FFImageLoading.Transformations"
             Padding="10" BackgroundColor="{ …
Run Code Online (Sandbox Code Playgroud)

c# data-binding xaml listview xamarin

1
推荐指数
1
解决办法
3472
查看次数

标签 统计

c# ×1

data-binding ×1

listview ×1

xamarin ×1

xaml ×1