This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Other code here... | |
// DO NOT use this code, it's faulty | |
global::Xamarin.Forms.Forms.SetFlags("CarouselView_Experimental"); | |
global::Xamarin.Forms.Forms.SetFlags("IndicatorView_Experimental"); | |
// Other code here... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class FavFightersView : ContentPage | |
{ | |
public FavFightersView() | |
{ | |
InitializeComponent(); | |
BindingContext = new FavFightersViewModel(); | |
// Catch the message here and show the alert | |
MessagingCenter.Subscribe<Fighter>(this, "Favorited", (f) => | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FavFightersViewModel : BindableObject | |
{ | |
ObservableCollection<Fighter> _fighters; | |
// Added this... | |
public Command<Fighter> FavoriteCommand { get; set; } | |
public FavFightersViewModel() | |
{ | |
LoadFighters(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<SwipeItemView Command="{Binding Path=BindingContext.FavoriteCommand, Source={x:Reference Name=FightersPage}}" CommandParameter="{Binding .}"> | |
<Grid | |
WidthRequest="120" | |
BackgroundColor="{StaticResource BackgroundColor}"> | |
<BoxView | |
Style="{StaticResource SwipeItemBorderStyle}"/> | |
<Image | |
Source="star.png" | |
Style="{StaticResource SwipeItemIconStyle}"/> | |
<Label |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class FavFightersView : ContentPage | |
{ | |
public FavFightersView() | |
{ | |
InitializeComponent(); | |
BindingContext = new FavFightersViewModel(); | |
} | |
// !!!!! This is the important part, right here !!!!! | |
void SwipeItemView_Invoked(System.Object sender, System.EventArgs e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Note the added Invoked attribute here --> | |
<SwipeItemView Invoked="SwipeItemView_Invoked"> | |
<Grid | |
WidthRequest="120" | |
BackgroundColor="{StaticResource BackgroundColor}"> | |
<BoxView | |
Style="{StaticResource SwipeItemBorderStyle}"/> | |
<Image | |
Source="star.png" | |
Style="{StaticResource SwipeItemIconStyle}"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<DataTemplate x:Key="MessageTemplate"> | |
<SwipeView | |
HeightRequest="110"> | |
<SwipeView.RightItems> | |
<SwipeItems | |
Mode="Reveal"> | |
<SwipeItemView> | |
<Grid | |
WidthRequest="120" | |
BackgroundColor="{StaticResource BackgroundColor}"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SwipeViewSample.MainPage"> | |
<StackLayout HorizontalOptions="Center" VerticalOptions="CenterAndExpand"> | |
<SwipeView> | |
<SwipeView.LeftItems> | |
<SwipeItems> | |
<SwipeItem Text="Favorite" | |
IconImageSource="favorite.png" | |
BackgroundColor="LightGreen" | |
Invoked="Favorite_Invoked" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SwipeViewSample.MainPage"> | |
<StackLayout HorizontalOptions="Center" VerticalOptions="CenterAndExpand"> | |
<SwipeView> | |
<SwipeView.LeftItems> | |
<SwipeItems> | |
<SwipeItem Text="Favorite" | |
IconImageSource="favorite.png" | |
BackgroundColor="LightGreen" | |
Invoked="Favorite_Invoked" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Xamarin.Forms; | |
namespace SwipeViewSample | |
{ | |
public partial class App : Application | |
{ | |
public App() | |
{ | |
InitializeComponent(); |