Skip to content

Instantly share code, notes, and snippets.

@ChaseFlorell
Created April 21, 2017 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChaseFlorell/2eaa7cb2865327e3e4cf730b165b76c9 to your computer and use it in GitHub Desktop.
Save ChaseFlorell/2eaa7cb2865327e3e4cf730b165b76c9 to your computer and use it in GitHub Desktop.
my idea of a xamarin forms listview
<ListView SeparatorWidth="2"
PullToRefreshCommand="{Binding Fetch}"
ItemTappedCommand="{Binding Navigate}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.ItemStyles>
<ViewCellItemStyle State="Normal" BackgroundColor="White" SeparatorColor="Red" />
<ViewCellItemStyle State="Pressed" BackgroundColor="Grey" SeparatorColor="Blue" />
<ViewCellItemStyle State="LongPressed" BackgroundColor="Green" SeparatorColor="Pink" />
<ViewCellItemStyle State="Selected" BackgroundColor="Yellow" SeparatorColor="Brown" />
</ViewCell.ItemStyles>
<ViewCell.ContextActions>
<MenuItem Icon="delete" Text="Delete" IsDestructive="True" Order="Primary" Command="{Binding Foo}" />
<MenuItem Icon="archive" Text="Archive" IsDestructive="False" Order="Secondary" Command="{Binding Bar}" />
</ViewCell.ContextActions>
<ViewCell.View>
<StackLayout>
<Label Text="Hello World" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
@ChaseFlorell
Copy link
Author

Notes

  1. the State on the ViewCellItemStyle will be an enum
  2. the Order on the MenuItem will be the left/right selector for iOS, and be the default primary/secondary for android (as it is now for ToolbarItem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment