0
votes

I have different Buttons that I want to put inside the <Frame> control, all this with the aim of avoiding the overflow of the image within the <ListView>, but when putting the HorizontalOptions and VerticalOptions property in FillAndExpand is not filling the Frame, I attached an image of the problem

screenshot

How can I make the <Button> inside the <Frame> fill the space? I have tried to give the Columns and Rows the Auto property and I have not succeeded.

How can I keep the size of the button (Height and Width) but without losing the frame? How can I fill and expand the button inside a Frame?

Any help for me?

VIEW.XAML:

<ListView 
                ItemsSource="{Binding ListaInventario}"
                SelectionMode="None"
                VerticalOptions="FillAndExpand"
                IsRefreshing="{Binding IsRefreshing, Mode=TwoWay}"               
                HasUnevenRows="True">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout
                                Margin="0,4,0,0"
                            Orientation="Vertical">

                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="1*" />
                                        <ColumnDefinition Width="5*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                         <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>

                                    <Label
                                        Text="{Binding Id}"                                    
                                        FontSize="Small"                 
                                        HorizontalOptions="Center"
                                        FontAttributes="Bold"
                                        HeightRequest="39"
                                        VerticalTextAlignment="Start"                                    
                                        TextColor="{StaticResource das.color.texto}"                                     
                                        Grid.Column="0"
                                        Grid.Row="0">
                                    </Label>

                                    <Label                                 
                                        Text="{Binding NombreComercial}"
                                        HorizontalOptions="Start"
                                        FontSize="Small" 
                                        MaxLines="3"
                                        HeightRequest="39"
                                        TextColor="{StaticResource das.color.texto}"
                                        VerticalOptions="Start"
                                        Grid.Column="1"
                                        Grid.Row="0">
                                    </Label>


                                    <Frame
                                        HorizontalOptions="End"
                                        BackgroundColor="Transparent"
                                        Grid.Column="2"
                                        Grid.Row="0">

                                         <Button 
                                        ImageSource="ic_pdf"
                                        HeightRequest="35"
                                        WidthRequest="50"
                                        BackgroundColor="{StaticResource das.color.estado_primary}"                                                  
                                        HorizontalOptions="FillAndExpand"
                                        VerticalOptions="FillAndExpand"                                          
                                        Command="{Binding HDSSisquimCommand}"/>

                                    </Frame>




                                </Grid>

                                <!---->

                                        <!--CANTIDAD-->
                                    <StackLayout
                                        Orientation="Horizontal"
                                        HorizontalOptions="FillAndExpand"
                                        Margin="0,1,0,2">

                                        <StackLayout               
                                              Orientation="Horizontal"
                                              HorizontalOptions="Start"
                                              Margin="0,0,3,0">
                                            <Label
                                                HorizontalOptions="Start"  
                                                HorizontalTextAlignment="Start"
                                                VerticalOptions="End"
                                                VerticalTextAlignment="Center"
                                                Text="Cantidad: "
                                                FontAttributes="Bold"
                                                FontSize="Small"
                                                HeightRequest="35"                    
                                                IsEnabled="{Binding EnabledEstimadoEntry}"></Label>
                                            <Entry
                                                HorizontalOptions="FillAndExpand"
                                                Placeholder="Cantidad"
                                                Keyboard="Numeric"
                                                HorizontalTextAlignment="Center"
                                                MaxLength="4"
                                                FontSize="Small"                                                   
                                                HeightRequest="35"
                                                Text="{Binding CantidadDecimal}"
                                                IsEnabled="{Binding EnabledContenedorEntry}">
                                                <VisualStateManager.VisualStateGroups>
                                                  <VisualStateGroup x:Name="CommonStatesEntry">
                                                  <VisualState x:Name="Normal">
                                                   <VisualState.Setters>
                                                     <Setter Property="BackgroundColor" Value="Transparent" />
                                                   </VisualState.Setters>
                                                 </VisualState>
                                                 <VisualState x:Name="Focused">
                                                    <VisualState.Setters>
                                                        <Setter Property="BackgroundColor" Value="LightGray" />
                                                    </VisualState.Setters>
                                                </VisualState>
                                                </VisualStateGroup>
                                              </VisualStateManager.VisualStateGroups>
                                            </Entry>
                                        </StackLayout>


                                        <!--UNIDAD-->
                                        <StackLayout             
                                            Orientation="Horizontal"
                                            HorizontalOptions="FillAndExpand">
                                            <Label
                                                HorizontalOptions="Start"  
                                                HorizontalTextAlignment="Start"
                                                VerticalOptions="End"
                                                VerticalTextAlignment="Center"
                                                Text="Unidad: "                                                    
                                                FontAttributes="Bold"
                                                FontSize="Small"
                                                HeightRequest="35"                    
                                                IsEnabled="{Binding EnabledEstimadoEntry}"></Label>
                                            <Picker 
                                                iOSSpecific:Picker.UpdateMode = "WhenFinished"
                                                ItemsSource="{Binding ListaUnidadesMedida}"
                                                SelectedItem="{Binding SelectedUnidadMedida}"
                                                ItemDisplayBinding="{Binding NombreCorto}"
                                                Title="Unidad"   
                                                FontSize="Small"
                                                HeightRequest="35"
                                                HorizontalOptions="FillAndExpand"
                                                IsEnabled="{Binding EnabledContenedor}">
                                                <VisualStateManager.VisualStateGroups>
                                                  <VisualStateGroup x:Name="CommonStatesPicker">
                                                      <VisualState x:Name="Normal">
                                                   <VisualState.Setters>
                                                     <Setter Property="BackgroundColor" Value="Transparent" />
                                                   </VisualState.Setters>
                                                 </VisualState>
                                                 <VisualState x:Name="Focused">
                                                    <VisualState.Setters>
                                                        <Setter Property="BackgroundColor" Value="LightGray" />
                                                    </VisualState.Setters>
                                                </VisualState>
                                                 </VisualStateGroup>
                                             </VisualStateManager.VisualStateGroups>
                                            </Picker>
                                        </StackLayout>


                                    </StackLayout>

                                <!-- TWO BUTTONS -->
                                <StackLayout
                                     Orientation="Horizontal"
                                        HorizontalOptions="End"
                                        Margin="0,1,0,2">

                                                <Button
                                                    Margin="0,0,2,0"
                                            ImageSource="ic_actualizar"                                              
                                            BackgroundColor="{Binding ColorBotonActualizar}"                                                       
                                            HorizontalOptions="End"
                                            VerticalOptions="Center"
                                            HeightRequest="35"
                                            WidthRequest="50"
                                            Command="{Binding ActualizarSQCommand}"/>

                                               <Button                                              
                                            ImageSource="ic_minus_sisquim"                                              
                                            BackgroundColor="{StaticResource das.color.estado_danger}"                                                       
                                            HorizontalOptions="End"
                                            VerticalOptions="Center"
                                            HeightRequest="35"
                                            WidthRequest="50"
                                            Command="{Binding DesasociarSQCommand}"/>

                                </StackLayout>

                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
2

2 Answers

3
votes

I only needed to set Padding="0" in the frame.

HorizontalOptions and VerticalOptions where not necessary to set as @Jessie Zhang -MSFT suggested.

<Frame Padding="0">
    <Button />
</Frame>
1
votes

You can try to added a property Padding="0" to Frame and remove the following properties of Button.

HeightRequest="35"
WidthRequest="50"

So the code is like this:

                           <Frame
                                    HorizontalOptions="End"
                                    BackgroundColor="Green"
                                    Grid.Column="2"
                                    Padding="0"
                                    Grid.Row="0">

                                <Button 
                                    Text="test"
                                    BackgroundColor="Accent"
                                    HorizontalOptions="FillAndExpand"
                                    VerticalOptions="FillAndExpand"                                          
                                   />
                            </Frame>