Skip to content

Instantly share code, notes, and snippets.

@hamid-shaikh
Created June 18, 2019 06:25
Show Gist options
  • Save hamid-shaikh/ada51d3605ab744aadd12f5991bbd822 to your computer and use it in GitHub Desktop.
Save hamid-shaikh/ada51d3605ab744aadd12f5991bbd822 to your computer and use it in GitHub Desktop.
AppAttachProperties usage example
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:appHelpers="clr-namespace:ProjectName.Mobile.Helpers"
x:Class="ProjectName.Mobile.Views.TestPage">
<!--ContentPage Content-->
<Grid
BackgroundColor="{StaticResource whiteColor}"
RowSpacing="0"
ColumnSpacing="0">
<Grid.RowDefinitions>
<RowDefinition
Height="*" />
<RowDefinition
Height="Auto" />
</Grid.RowDefinitions>
<Image
VerticalOptions="EndAndExpand"
DownsampleToViewSize="true"
Aspect="AspectFit"
HeightRequest="270"
Grid.Row="1"
appHelpers:AppAttachProperties.TapCommand="{Binding SomeViewModelCommand}"
appHelpers:AppAttachProperties.TapCommandParameter="{Binding SomeProperty}" <!--You can also specify some static value-->
Source="someIcon.png" />
<StackLayout
x:Name="parentStackLayout"
Margin="24, 0"
VerticalOptions="EndAndExpand"
Spacing="30">
<Label
appHelpers:AppAttachProperties.TapCommand="{Binding SomeViewModelCommand}"
appHelpers:AppAttachProperties.TapCommandParameter="{Binding SomeProperty}" <!--You can also specify some static value-->
appHelpers:AppAttachProperties.AnimateView="{Binding Source={x:Reference parentStackLayout}}"<!--Here i have attached AnimateView and passed stacklayout object which should be animated when label is clicked-->
VerticalOptions="Center"
Text="Label Text"
Style="{StaticResource primaryLabelStyle}" />
<Button
Text="Button Text"
appHelpers:AppAttachProperties.TapCommand="{Binding SomeViewModelCommand}"
appHelpers:AppAttachProperties.TapCommandParameter="{Binding SomeProperty}" <!--You can also specify some static value-->
appHelpers:AppAttachProperties.AnimateOnTap="False"
Style="{StaticResource primaryButtonStyle}" />
</StackLayout>
</Grid>
</ContentPage>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment