Last active
August 10, 2018 00:34
-
-
Save tuyen-vuduc/4b8ea23bc93a224f7657d4eb2ae9a004 to your computer and use it in GitHub Desktop.
Custom control with public command
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
<ContentPage x:name="page"> | |
<ListView> | |
<ListView.ItemTemplate> | |
<DataTemplate> | |
<ViewCell> | |
<CustomControl Command="{Binding BindingContext.ShowItemCommand, Source={Reference page}}" /> | |
</ViewCell> | |
</DataTemplate> | |
</ListView.ItemTemplate> | |
</ListView> | |
</ContentPage> |
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 x:Name="view"> | |
<Button Text="Click me!" Command="{Binding Command, Source={Reference view}" /> | |
</ContentView> |
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 CustomControl : ContentView { | |
public static readonly BindableProperty CommandProperty = | |
BindableProperty.Create("ICommand", typeof(ICommand), typeof(CustomControl), null, null); | |
public ICommand Command | |
{ | |
get { return GetValue(CommandProperty); } | |
set { SetValue(CommandProperty, value); } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment