微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

列表视图自动大小保持,或删除不必要的列表视图空间

如何解决列表视图自动大小保持,或删除不必要的列表视图空间

这是我的复选框页面,我使用网格分隔(字典,集合,参考),每个部分都有一个列表视图,我想删除字典部分中显示的不必要的空间,还想自动增加大小。我有使用列表视图显示复选框,所有部分都保持思想网格

enter image description here

这是我的复选框页面,我使用网格将列表分隔开,我想删除字典部分中显示的不必要空间,还想自动增加大小。我使用列表视图来显示复选框,所有部分都是维护思维网格

这是我的代码

<StackLayout  Padding="10" Grid.Column="0" Orientation="Vertical" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
                            
                            <Grid>
                                    <Grid.RowDeFinitions>
                                        
                                        <RowDeFinition Height="3*"/>
                                        <RowDeFinition Height="2*"/>
                                        <RowDeFinition Height="2*"/>
                                        <RowDeFinition Height="3*"/>
                                    </Grid.RowDeFinitions>


                                <StackLayout Grid.Row="0"  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Orientation="Vertical">
                                    <Label Margin="-15,0"   HorizontalOptions="StartAndExpand"  Text="{x:Static resources:AppResources.Dictionaries}" Style="{StaticResource MenueLable}" ></Label>

                                    <ListView BackgroundColor="White"  ItemsSource="{Binding DictionariesFilter}" VerticalOptions="FillAndExpand" HasUnevenRows="True"  SeparatorVisibility="None" RowHeight="-1">
                                        <ListView.ItemTemplate >
                                            <DataTemplate >
                                                <ViewCell Tapped="Handle_Tapped" >
                                                    <StackLayout  Orientation="Horizontal">
                                                        <input:CheckBox  Style="{StaticResource CheckBox}" IsChecked="{Binding                                                                  IsChecked}" Type="Check" CheckChangedCommand="{Binding                                                                                      Path=BindingContext.CheckBoxSelectionCommand,Source={x:Reference Name=entriesView}}"/>
                                                        <Label Text="{Binding DicName}" VerticalTextAlignment="Center" ></Label>
                                                    </StackLayout>
                                                </ViewCell>
                                            </DataTemplate>
                                        </ListView.ItemTemplate>
                                    </ListView>

                                    <Button  Text="Load More" IsVisible="False"  TextColor="#22B473"  FontAttributes="Bold" HorizontalOptions="Center" VerticalOptions="Start"></Button>
                                    <Line Background="#F0F0F0" HeightRequest="2" ></Line>

                                </StackLayout>

                                <StackLayout Grid.Row="1" VerticalOptions="FillAndExpand" Orientation="Vertical">
                                        <Label Margin="-25,0" Text="{x:Static resources:AppResources.Collection}" VerticalOptions="StartAndExpand" HorizontalOptions="StartAndExpand"  Style="{StaticResource MenueLable}"></Label>
                                    <ListView ItemsSource="{Binding CollectionsFilter}" HasUnevenRows="True"   BackgroundColor="White"  SeparatorVisibility="None" RowHeight="-1" >
                                            <ListView.ItemTemplate>
                                                <DataTemplate>
                                                <ViewCell  Tapped="Handle_Tapped">
                                                        <StackLayout Orientation="Horizontal"  >
                                                        <input:CheckBox Style="{StaticResource CheckBox}" Type="Check" 
                                                           CheckChangedCommand="{Binding  Path=BindingContext.CheckBoxSelectionCommand,Source={x:Reference Name=entriesView}}"/>
                                                        <Label Text="{Binding DicName}" VerticalTextAlignment="Center" ></Label>
                                                    </StackLayout>
                                                    </ViewCell>
                                                </DataTemplate>
                                            </ListView.ItemTemplate>
                                        </ListView>
                                        <Line Background="#F0F0F0" HeightRequest="2"></Line>
                                    </StackLayout>

                                    <StackLayout Grid.Row="2"   VerticalOptions="FillAndExpand" Orientation="Vertical">
                                        <Label Margin="-20,0" VerticalOptions="StartAndExpand" HorizontalOptions="StartAndExpand"   Text="{x:Static resources:AppResources.References}"  Style="{StaticResource MenueLable}"></Label>
                                        <ListView HasUnevenRows="True" BackgroundColor="White"  ItemsSource="{Binding RefrencesFilter}" SeparatorVisibility="None" >
                                            <ListView.ItemTemplate>
                                                <DataTemplate>
                                                    <ViewCell>
                                                        <StackLayout Orientation="Horizontal"  >
                                                        <input:CheckBox Style="{StaticResource CheckBox}"  Type="Check" 
                                                           CheckChangedCommand="{Binding  Path=BindingContext.CheckBoxSelectionCommand,Source={x:Reference Name=entriesView}}"/>
                                                        <Label Text="{Binding DicName}" VerticalTextAlignment="Center" ></Label>
                                                    </StackLayout>
                                                    </ViewCell>
                                                </DataTemplate>
                                            </ListView.ItemTemplate>
                                        </ListView>
                                        <Line Background="#F0F0F0" HeightRequest="2"></Line>
                                    </StackLayout>
                                <ScrollView Grid.Row="3">
                                    <StackLayout  VerticalOptions="StartAndExpand" HorizontalOptions="StartAndExpand" Orientation="Vertical">

                                        <Label Margin="0,0" VerticalOptions="StartAndExpand" HorizontalOptions="StartAndExpand"    Text="{x:Static resources:AppResources.CategorisedBy}"  Style="{StaticResource MenueLable}"></Label>

                                        <input:CheckBox Margin="-10,0" IsChecked="{Binding IsSelected}" Style="{StaticResource CheckBox}" Text="{x:Static resources:AppResources.Categorised_ByCheckBox1}"  Type="Check"   CheckChangedCommand="{Binding  Path=BindingContext.CheckBoxSelectionCommand,Source={x:Reference Name=entriesView}}"/>
                                        <input:CheckBox Margin="-10,0" Style="{StaticResource CheckBox}" IsChecked="{Binding IsSelected}" Text="{x:Static resources:AppResources.Categorised_ByCheckBox2}"  Type="Check"   CheckChangedCommand="{Binding  Path=BindingContext.CheckBoxSelectionCommand,0" IsChecked="{Binding IsSelected}" Style="{StaticResource CheckBox}" Text="{x:Static resources:AppResources.Categorised_ByCheckBox3}" Type="Check"   CheckChangedCommand="{Binding  Path=BindingContext.CheckBoxSelectionCommand,0" IsChecked="{Binding IsSelected}" Style="{StaticResource CheckBox}" Text="{x:Static resources:AppResources.Categorised_ByCheckBox4}" Type="Check"   CheckChangedCommand="{Binding  Path=BindingContext.CheckBoxSelectionCommand,Source={x:Reference Name=entriesView}}"/>


                                    </StackLayout>
                                </ScrollView>
                                   

                                </Grid>


                            </StackLayout>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。