NetMaui - CollectionView 未在 Android 上显示

问题描述 投票:0回答:1

我创建了一个 NetMaui 应用程序,在页面中我有一个集合视图 当我在 Windows 中执行应用程序时,我没有问题,但在 Android 中,集合视图没有显示

我在调试和发布时遇到这个问题 在此输入图片描述

android maui collectionview
1个回答
0
投票
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:converters="clr-namespace:Commessa2005.Daht.Produzione.Maui.Converters"
             x:Class="Commessa2005.Daht.Produzione.Maui.Pages.P41_DichiaraProduzione"
             xmlns:controls="clr-namespace:Commessa2005.Daht.Produzione.Maui.Controls"
             xmlns:model="clr-namespace:Commessa2005.Daht.Shared.Models"
             Title=""
             NavigationPage.HasNavigationBar="false" 
             Shell.NavBarIsVisible="true"
             xmlns:viewModel="clr-namespace:Commessa2005.Daht.Produzione.Maui.ViewModels"
             x:DataType="viewModel:ConsProduzioneViewModel"
             xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls"
             >
    <!-- xmlns:model="clr-namespace:Commessa2005.Daht.Shared.Models;assembly=Commessa2005.Daht.Shared" -->
    <!-- xmlns:model="clr-namespace:Commessa2005.Daht.Shared.Models" -->
    <ContentPage.Resources>
        <converters:InvertedBoolConverter x:Key="InvertedBoolConverter" />
    </ContentPage.Resources>

    <VerticalStackLayout Margin="0"
                     Spacing="3" 
                     >
        <controls:TitleBar />
        <Label 
                Text="DICHIARA PRODUZIONE"
                Style="{DynamicResource LargeLabel}"
                VerticalOptions="Center" 
                HorizontalOptions="Center" />
        <Label  Text="Quantità prodotta"
                Style="{DynamicResource MediumLabel}"
                VerticalOptions="Center" 
                HorizontalOptions="Center" />
        <StackLayout Orientation="Horizontal" IsEnabled="{Binding IsNotBusy}">
            <Frame ZIndex="1" HasShadow="True" 
                       BorderColor="{AppThemeBinding Light={DynamicResource LightEntryBackground}, Dark={DynamicResource DarkEntryBackground}}" 
                       HeightRequest="56" WidthRequest="56" CornerRadius="28">
                <Image Source="tastierino_48.png" 
                           HeightRequest="30" 
                           WidthRequest="30" 
                           HorizontalOptions="Center" 
                           VerticalOptions="Center" 
                           Margin="-8,-8,0,0"/>
            </Frame>
            <Frame HeightRequest="45" Margin="-20,0,0,0" Padding="0" HasShadow="True" BorderColor="White"  HorizontalOptions="FillAndExpand">
                <Entry x:Name="QtaProdotta"
                        Style="{DynamicResource BaseEntry}"
                        Placeholder="Inserire la nuova quantita prodotta"
                        HorizontalOptions="Center"
                        Keyboard="Numeric"
                        Text="{Binding QtaProdotta}"
                        android:Entry.ImeOptions="Next" 
                        Completed="OnQtaProdottaInserita"
                   />
            </Frame>
        </StackLayout>
        <StackLayout Orientation="Horizontal" IsEnabled="{Binding IsNotBusy}">
            <Frame ZIndex="2" HasShadow="True" 
                       BorderColor="{AppThemeBinding Light={DynamicResource LightEntryBackground}, Dark={DynamicResource DarkEntryBackground}}" 
                       HeightRequest="56" WidthRequest="56" CornerRadius="28">
                <Image Source="tastierino_48.png" 
                           HeightRequest="30" 
                           WidthRequest="30" 
                           HorizontalOptions="Center" 
                           VerticalOptions="Center" 
                           Margin="-8,-8,0,0"/>
            </Frame>
            <Frame HeightRequest="45" Margin="-20,0,0,0" Padding="0" HasShadow="True" BorderColor="White"  HorizontalOptions="FillAndExpand">
                <Entry x:Name="Note"
                        Style="{DynamicResource BaseEntry}"
                        Placeholder="Annotazioni"
                        HorizontalOptions="Center"
                        Text="{Binding Annotazioni}"
                        ReturnType="Go"
                   />
            </Frame>
        </StackLayout>
        <Grid ColumnDefinitions="*,*">
            <Switch x:Name="StampaEtich"
                    HorizontalOptions="Start"
                    Grid.Column="1"
                    IsToggled="{Binding StampaEtichetta}"
                    />
            <Label Text="Stampa etichette"
                HorizontalOptions="Center"
                Style="{StaticResource MediumLabel}"
                Grid.Column="0"
                   />
        </Grid>
        <Grid ColumnDefinitions="*,*">
            <Button 
                    x:Name="Annulla"
                    Text="Annulla"
                    Grid.Column="0"
                    FontSize="24"
                    Clicked="OnAnnullaClicked"
                    VerticalOptions="CenterAndExpand" 
                    HorizontalOptions="Fill"
                    HeightRequest="50"
                    
                    />
            <!-- Style="{StaticResource ButtonOutline}"-->
            <Button 
                    x:Name="Conferma"
                    Text="Conferma"
                    Grid.Column="1"
                    FontSize="24"
                    Clicked="OnDichiaraProdClicked"
                    VerticalOptions="CenterAndExpand" 
                    HorizontalOptions="Fill"
                    HeightRequest="50"
                    />
        </Grid>        

        <ActivityIndicator x:Name="Attesa" IsVisible="{Binding IsBusy}"
                        IsRunning="{Binding IsBusy}" Color="Red"
                        WidthRequest="20"
                        HeightRequest="20"/>

        <ScrollView VerticalScrollBarVisibility="Always" VerticalOptions="Start">
            
            <Grid   ColumnDefinitions="*"
                    ColumnSpacing="0"
                    RowDefinitions="*">

                <Grid   Grid.Row="0"
                        IsVisible="{Binding IsErrorPresent,Converter={StaticResource InvertedBoolConverter}}"
                        ColumnDefinitions="*"
                        ColumnSpacing="5"
                        RowDefinitions="*">
                    <RefreshView x:Name="RefreshView"
                    Command="{Binding GetMaterialiCommand}"
                    IsRefreshing="{Binding IsRefreshing}"
                             >

                        <!-- TODO: Senza HeightRequest non scrolla BUG MAUI-->
                        <!--  BackgroundColor="Transparent" -->
                        <CollectionView x:Name="ListaMateriali" 
                                BackgroundColor="Yellow"
                            ItemsSource="{Binding Materiali}"
                            SelectionMode="Single"
                            HeightRequest="430"
                            >
                            <CollectionView.EmptyView>

                                <StackLayout VerticalOptions="Center"
                                 HorizontalOptions="Center"
                                 WidthRequest="200"
                                 HeightRequest="200">

                                    <Image Source="nodata.png"
                                       HorizontalOptions="CenterAndExpand"
                                       VerticalOptions="CenterAndExpand"
                                       Aspect="AspectFill" />

                                </StackLayout>

                            </CollectionView.EmptyView>

                            <CollectionView.ItemTemplate>
                                <DataTemplate x:DataType="model:MaterialeUtilizzatoDetails">

                                    <Grid Padding="5" RowDefinitions="140">

                                        <Frame 
                                        Padding="0"
                                        Style="{StaticResource CardView}">
                                            <!--
                                        <Frame.GestureRecognizers>
                                            <TapGestureRecognizer 
                                            Command="{Binding Source={RelativeSource AncestorType={x:Type viewModel:ConsProduzioneViewModel}}, Path=XXX}"
                                            CommandParameter="{Binding .}"/>
                                        </Frame.GestureRecognizers>
                                        -->
                                            <Grid Padding="0"
                                            ColumnDefinitions="125,*">
                                                <VerticalStackLayout Grid.Column="0"
                                                         Padding="10"
                                                         VerticalOptions="Center">
                                                    <Image Aspect="AspectFill"
                                                    Source="nodata.png" 
                                                    WidthRequest="100"
                                                    HeightRequest="100" />
                                                    <Label Text="{Binding idProdotto,StringFormat='Cod.Prodotto {0}'}"
                                                        Style="{StaticResource MicroLabel}"
                                                       MaxLines="1"/>
                                                </VerticalStackLayout>
                                                <VerticalStackLayout Grid.Column="1"
                                                         Padding="10"
                                                         VerticalOptions="Center">
                                                    <Label Text="{Binding codarticolointerno}"
                                               Style="{StaticResource SmallLabel}"
                                               MaxLines="1"/>
                                                    <Label Text="{Binding prodotto}"
                                               Style="{StaticResource SmallLabel}"
                                               MaxLines="2"/>

                                                    <Grid   x:Name="Produzione"
                                                            Padding="0"
                                                            RowDefinitions="*,*"
                                                            ColumnDefinitions="100,*,50"
                                                            HorizontalOptions="FillAndExpand">
                                                        <Label  Grid.Column="0"
                                                                Grid.Row="0"
                                                                HorizontalTextAlignment="Start"
                                                                Text="{Binding descrTipoMatUsato}"
                                                                Style="{StaticResource SmallLabel}"
                                                                TextColor="{AppThemeBinding Light={StaticResource LightLabelEvidenceText}, Dark={StaticResource DarkLabelEvidenceText}}"
                                                        />
                                                        <Entry  x:Name="IDCaricoMag"
                                                            Grid.Column="1"
                                                            Grid.Row="0"
                                                            Keyboard="Numeric"
                                                            Style="{DynamicResource BaseEntry}"
                                                            Placeholder="IDCarico Mag."
                                                            Text="{Binding idCaricoMag}"
                                                            IsVisible="{Binding isDaProduzione, Converter={StaticResource InvertedBoolConverter}}"
                                                            IsEnabled="{Binding isMagazzinoPers, Converter={StaticResource InvertedBoolConverter}}"
                                                            android:Entry.ImeOptions="Next" 
                                                            Completed="OnIDCaricoMagInserito"
                                                           
                                                        />
                                                       
                                                        <Entry  x:Name="LottoMat_Utilizz"
                                                            Grid.Column="1"
                                                            Grid.Row="0"
                                                            Keyboard="Numeric"
                                                            Style="{DynamicResource BaseEntry}"
                                                            Placeholder="LottoMat. Prod."
                                                            Text="{Binding lottoMat_Utilizzo}"
                                                            IsVisible="{Binding isDaProduzione}"
                                                            android:Entry.ImeOptions="Next" 
                                                            Completed="OnLottoMat_UtilizzInserito"

                                                           />
                                                        <Label  Grid.Column="0"
                                                                Grid.Row="1"
                                                                Text="{Binding um}"
                                                                HorizontalTextAlignment="Start"
                                                                Style="{StaticResource SmallLabel}" 
                                                                IsVisible="{Binding isMagazzinoPers, Converter={StaticResource InvertedBoolConverter}}"/>
                                                        <Entry  x:Name="Qta"
                                                            Grid.Row="1"
                                                            Grid.Column="1"
                                                            Keyboard="Numeric"
                                                            Style="{DynamicResource BaseEntry}"
                                                            Placeholder="{Binding qtaUtilizzataCalcolataAuto}"
                                                            Text="{Binding qtaUtilizzata}"
                                                            IsVisible="{Binding isMagazzinoPers, Converter={StaticResource InvertedBoolConverter}}"
                                                            android:Entry.ImeOptions="Next" 
                                                            Completed="OnQtaInserita"
                                                            />
                                                        <Image  Source="qrcode.png" 
                                                                Grid.Column="2"
                                                                Grid.Row="0"
                                                                Grid.RowSpan="2"
                                                                HeightRequest="30" 
                                                                WidthRequest="30" 
                                                                HorizontalOptions="Center" 
                                                                VerticalOptions="Center" 
                                                                Margin="0,0,0,0"
                                                                IsVisible="{Binding isMagazzinoPers, Converter={StaticResource InvertedBoolConverter}}"
                                                        >
                                                            <Image.GestureRecognizers>
                                                                <TapGestureRecognizer 
                                                                    Command="{Binding Source={RelativeSource AncestorType={x:Type viewModel:ConsProduzioneViewModel}}, Path=ReadBarcodeMaterialeUtilizzatoCommand}"
                                                                    CommandParameter="{Binding .}"
                                                                    Tapped="OnBarcodeTapped"
                                                                    NumberOfTapsRequired="1"
                                                                />
                                                            </Image.GestureRecognizers>
                                                        </Image>

                                                    </Grid>


                                                </VerticalStackLayout>

                                            </Grid>

                                        </Frame>

                                    </Grid>

                                </DataTemplate>
                            </CollectionView.ItemTemplate>

                        </CollectionView>

                    </RefreshView>
                </Grid>
                <Label  IsVisible="{Binding IsErrorPresent}"
                        Text="{Binding Error}"
                        Style="{DynamicResource ErrorLabel}"
                        Grid.Row="1"
                        HorizontalOptions="Center">
                    <Label.GestureRecognizers>
                        <TapGestureRecognizer  
                        Command="{Binding Source={RelativeSource AncestorType={x:Type viewModel:ConsProduzioneViewModel}}, Path=ResetErrorCommand}"
                        CommandParameter="{Binding .}"/>
                    </Label.GestureRecognizers>
                </Label>
            </Grid>
        </ScrollView> 

        


    </VerticalStackLayout>

</ContentPage>
© www.soinside.com 2019 - 2024. All rights reserved.