Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Frame Margin in xamarin?

I am creating Listview using custom cell. I am using Frame inside the Viewcell. It displays fine in Android device, but in IOS it doesn't display Margins between two Frames. How can I set this for IOS?

Code of Viewcell is:

 <ViewCell>
    <StackLayout>
      <Frame Margin="10" BackgroundColor="White" CornerRadius="5" HasShadow="False"  IsClippedToBounds="False">
       <StackLayout>
          <Label Text="{Binding Name}" FontFamily="Raleway-Regular" FontSize="24" TextColor="#262628" HorizontalTextAlignment="Center" FontAttributes="Bold"></Label>
          <Label Text="{Binding Description1}" FontSize="15" HorizontalTextAlignment="Center" TextColor="#262628" FontAttributes="Bold" Margin="0,5"></Label>
          <ContentView HorizontalOptions="Center"  Padding="0" Content="{Binding IngredientsArray1, Converter={StaticResource arrayToStackLayout}}" />
       </StackLayout>
      </Frame>
     </StackLayout>
 </ViewCell>

IOS Output is :

image

like image 605
Srusti Thakkar Avatar asked Mar 20 '18 04:03

Srusti Thakkar


People also ask

What is margin in xamarin?

The Margin property represents the distance between an element and its adjacent elements, and is used to control the element's rendering position, and the rendering position of its neighbors. Margin values can be specified on layout and view classes.

How do you increase the border width of a frame in xamarin?

There is no such built-in property for Frame to set border width. An alternative way is nesting a Frame within another Frame. The following is the demo xaml. You can set the "border width" by setting the property Margin.

What is frame in xamarin?

The Xamarin. Forms Frame class is a layout used to wrap a view with a border that can be configured with color, shadow, and other options. Frames are commonly used to create borders around controls but can be used to create more complex UI.


Video Answer


1 Answers

I have just Changed My code From above to this:

 <ViewCell>
                <ContentView>
                    <Frame Margin="10" BackgroundColor="White" CornerRadius="5" HasShadow="False"  IsClippedToBounds="True">
                        <StackLayout Margin="5">
                            <Label Text="{Binding Name}" FontFamily="Raleway-Bold" FontSize="24" TextColor="#262628" HorizontalTextAlignment="Center" FontAttributes="Bold"></Label>
                            <Label Text="{Binding Description1}" FontSize="15" HorizontalTextAlignment="Center" TextColor="#262628" FontAttributes="Bold" Margin="0,5"></Label>
                            <ContentView HorizontalOptions="Center"  Padding="0" Content="{Binding IngredientsArray1, Converter={StaticResource arrayToStackLayout}}" />
                        </StackLayout>
                    </Frame>
                </ContentView>
            </ViewCell>
like image 159
Srusti Thakkar Avatar answered Oct 15 '22 23:10

Srusti Thakkar