Guest User

Untitled

a guest
Nov 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. <StackLayout>
  2. <ListView HorizontalOptions="FillAndExpand" ItemsSource="{Binding EquipmentList}">
  3. <ListView.ItemTemplate>
  4. <DataTemplate>
  5. <ViewCell>
  6. <StackLayout Orientation="Horizontal">
  7. <Label Text="{Binding Name}" />
  8. <Switch IsToggled="{Binding State}" />
  9. <Button
  10. Command="{Binding BindingContext.DoCommand, Source={x:Reference TestPage}}"
  11. CommandParameter="{Binding .}"
  12. IsVisible="{Binding State}"
  13. Text="Click" />
  14. </StackLayout>
  15. </ViewCell>
  16. </DataTemplate>
  17. </ListView.ItemTemplate>
  18. </ListView>
  19. </StackLayout>
  20.  
  21. private Command<Equipment> _doCommand;
  22. public Command<Equipment> DoCommand => _doCommand ??
  23. (_doCommand = new Command<Equipment>((Equipment obj) => HandleEquipment(obj)));
  24.  
  25.  
  26. // Outputs correct Name and State of the list item
  27. private void HandleEquipment(Equipment obj)
  28. {
  29. System.Diagnostics.Debug.WriteLine(obj.Name + ", " + obj.State);
  30. }
Add Comment
Please, Sign In to add comment