Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <StackLayout>
- <ListView HorizontalOptions="FillAndExpand" ItemsSource="{Binding EquipmentList}">
- <ListView.ItemTemplate>
- <DataTemplate>
- <ViewCell>
- <StackLayout Orientation="Horizontal">
- <Label Text="{Binding Name}" />
- <Switch IsToggled="{Binding State}" />
- <Button
- Command="{Binding BindingContext.DoCommand, Source={x:Reference TestPage}}"
- CommandParameter="{Binding .}"
- IsVisible="{Binding State}"
- Text="Click" />
- </StackLayout>
- </ViewCell>
- </DataTemplate>
- </ListView.ItemTemplate>
- </ListView>
- </StackLayout>
- private Command<Equipment> _doCommand;
- public Command<Equipment> DoCommand => _doCommand ??
- (_doCommand = new Command<Equipment>((Equipment obj) => HandleEquipment(obj)));
- // Outputs correct Name and State of the list item
- private void HandleEquipment(Equipment obj)
- {
- System.Diagnostics.Debug.WriteLine(obj.Name + ", " + obj.State);
- }
Add Comment
Please, Sign In to add comment