Swathy
Swathy

Reputation: 219

How to give a shadow effect to a frame in xamarin forms

I am new in xamarin I wan to add a shadow effect to my frame and avoid the top border line of my frame, I tried "hasShadow" property of frame but that doesn't help me. How can I do this.

Please help me

Here is my Xaml

 <ListView x:Name="lv_search" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" RowHeight="105" ItemTapped="lv_search_ItemTapped"
                          SeparatorColor="White" BackgroundColor="Black" Margin="0,15,0,0">
                    <ListView.ItemTemplate>
                      <DataTemplate>
                        <ViewCell>
                          <Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="White">
                            <Grid Margin="20,10,0,10" BackgroundColor="White">
                              <Frame  BackgroundColor="White" >
                                <StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
                                  <StackLayout Orientation="Horizontal" HorizontalOptions="StartAndExpand" VerticalOptions="FillAndExpand" Margin="0,0,10,0">
                                    <AbsoluteLayout  HorizontalOptions="StartAndExpand">
                                      <Image Source="ellipse_1" VerticalOptions="CenterAndExpand" HorizontalOptions="FillAndExpand"
                                         AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0.01,0.4,1,1" BackgroundColor="White"/>
                                         <Image Source="{Binding Image}" AbsoluteLayout.LayoutBounds="0.02,0.4,1,1" AbsoluteLayout.LayoutFlags="All"
                                           HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"  />
                                    </AbsoluteLayout>

                                    <StackLayout AbsoluteLayout.LayoutBounds="0.035,0.5,1,1" AbsoluteLayout.LayoutFlags="All" Orientation="Horizontal"
                                      HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand">
                                      <Label x:Name="lbl_categories" HorizontalOptions="StartAndExpand" VerticalOptions="CenterAndExpand" 
                                        Margin="10,0,0,0" FontFamily="Proxima-Nova-Semibold"  TextColor="#222222"  Text="{Binding Title}" 
                                        LineBreakMode="WordWrap"  HorizontalTextAlignment="Start" FontSize="17.3" FontAttributes="Bold"/>
                                    </StackLayout>
                                    </StackLayout>
                                     <Image HorizontalOptions="EndAndExpand" VerticalOptions="Center" Source="arrow"  
                                       AbsoluteLayout.LayoutBounds="0.9,0.3,0,0.3" AbsoluteLayout.LayoutFlags="All" />
                                 </StackLayout>
                               </Frame>
                          </Grid>
                           <Image Source="img_frm" Margin="15,0,0,0" AbsoluteLayout.LayoutBounds="1,0.5,1,1" HorizontalOptions="StartAndExpand"
                            AbsoluteLayout.LayoutFlags="All"/>
                       </Grid>
                    </ViewCell>
                  </DataTemplate>
                </ListView.ItemTemplate>
             </ListView>

The code gives this output

enter image description here

But I want a page like this enter image description here

The page difference is marked by blue ink.

Upvotes: 0

Views: 10681

Answers (2)

dan_udnas
dan_udnas

Reputation: 29

You can use the HasShadow="True" atribute on Frame definition.

Where did you place the HasShadow? It need to be like this

<i> <Frame HasShadow="True" ...> </Frame> </i> 

Upvotes: 1

Ali123
Ali123

Reputation: 797

This article by Alex Dunn looks like what you want exactly: enter image description here https://alexdunn.org/2018/06/06/xamarin-tip-dynamic-elevation-frames/

Note that you can control the Elevation as much as you want

Upvotes: 3

Related Questions