Skip to content

Instantly share code, notes, and snippets.

@rdelrosario
Created August 23, 2017 13:00
Show Gist options
  • Save rdelrosario/1bd612898c38207c6658e97c80fad97f to your computer and use it in GitHub Desktop.
Save rdelrosario/1bd612898c38207c6658e97c80fad97f to your computer and use it in GitHub Desktop.
DraggrableView Sample XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:DragViewSample"
x:Class="DragViewSample.MainPage">
<AbsoluteLayout>
<ListView AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0,0,1,1"
SeparatorColor="Transparent" x:Name="list"
Margin="0,20,0,0"
RowHeight="180" ItemSelected="Handle_ItemSelected"
ItemsSource="{Binding Items}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout VerticalOptions="Center">
<Image HeightRequest="140" Aspect="AspectFill" Source="{Binding Image}" HorizontalOptions="FillAndExpand"/>
<Label Text="{Binding Name}" HorizontalOptions="FillAndExpand"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackLayout AbsoluteLayout.LayoutFlags="All" x:Name="dragLayout"
AbsoluteLayout.LayoutBounds="0,0,1,1" IsVisible="false"
VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Image Source="close" Margin="10" HorizontalOptions="Start">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnCloseTapped" />
</Image.GestureRecognizers>
</Image>
<local:DraggableView x:Name="dragView" VerticalOptions="CenterAndExpand"
DragMode="LongPress" DragDirection="All" >
<local:DraggableView.Content>
<Image x:Name="image"
Source="{Binding ItemSelected.Image}"
Aspect="AspectFill"
HorizontalOptions="CenterAndExpand"
HeightRequest="200"
Margin="10,0"
VerticalOptions="CenterAndExpand"/>
</local:DraggableView.Content>
</local:DraggableView>
</StackLayout>
</AbsoluteLayout>
</ContentPage>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment