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
<ListView ItemsSource="{Binding ListData}" HasUnevenRows="True"> | |
<ListView.Behaviors> | |
<behaviors:EventToCommandBehavior EventName="ItemTapped" Command="{Binding ListItemSelected}" EventArgsConverter="{StaticResource ItemTappedEventArgsConverter}" /> | |
</ListView.Behaviors> | |
<ListView.ItemTemplate> | |
<DataTemplate> | |
<ViewCell> | |
<!- your layout here--> | |
</ViewCell> |
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 ItemTappedEventArgsConverter : IValueConverter | |
{ | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
var eventArgs = value as ItemTappedEventArgs; | |
if (eventArgs == null) | |
throw new ArgumentException("Expected TappedEventArgs as value", "value"); | |
return eventArgs.Item; | |
} |
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 FirstValidationErrorConverter : IValueConverter | |
{ | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
ICollection<string> errors = value as ICollection<string>; | |
return errors != null && errors.Count > 0 ? errors.ElementAt(0) : null; | |
} | |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |
{ |
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 BooleanNegationConverter : IValueConverter | |
{ | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
return !(bool)value; | |
} | |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
return !(bool)value; |
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 MyConverter : IValueConverter | |
{ | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
// do something to get a new value | |
} | |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
// and change it back if you want to |
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
<Grid> | |
<ScrollView Grid.Row="0"> | |
<StackLayout> | |
<!-- main content here --> | |
</StackLayout> | |
</ScrollView> | |
<controls:Modal | |
Grid.Row="0" | |
ModalHeader="Help Text" |
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 | |
x:Class="XamarinModalExample.MainView" | |
xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
xmlns:controls="clr-namespace:XamarinModalExample.Controls;assembly=XamarinModalExample"> |
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
namespace XamarinModalExample.Controls | |
{ | |
[XamlCompilation(XamlCompilationOptions.Compile)] | |
public partial class Modal : ContentView | |
{ | |
public static readonly BindableProperty ShowModalProperty | |
= BindableProperty.Create(nameof(ShowModal), typeof(bool), typeof(Modal), defaultValue: false, defaultBindingMode: BindingMode.TwoWay, propertyChanged: ShowModalPropertyChanged); | |
public static readonly BindableProperty ModalHeaderProperty | |
= BindableProperty.Create(nameof(ModalHeader), typeof(string), typeof(Modal), defaultValue: string.Empty, defaultBindingMode: BindingMode.TwoWay); |
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
<ContentView.ControlTemplate> | |
<ControlTemplate> | |
<StackLayout | |
BackgroundColor="#4f000000" | |
HorizontalOptions="Fill" | |
VerticalOptions="Fill"> | |
<Frame | |
Margin="15,25" | |
Padding="5" | |
Style="{StaticResource ModalStyle}" |
NewerOlder