private async void OnSublayersClicked(object sender, EventArgs e)
{
// Make sure that layer and it's sublayers are loaded
// If layer is already loaded, this returns directly
await _imageLayer.LoadAsync();
// Create layout for sublayers page
// Create root layout
var layout = new StackLayout();
// Create list for layers
var sublayersTableView = new TableView();
// Create section for basemaps sublayers
var sublayersSection = new TableSection(_imageLayer.Name);
// Create cells for each of the sublayers
foreach (ArcGISSublayer sublayer in _imageLayer.Sublayers)
{
// Using switch cells that provides on/off functionality
SwitchCell cell = new SwitchCell()
{
Text = sublayer.Name,
On = sublayer.IsVisible
};
// Hook into the On/Off changed event
cell.OnChanged += OnCellOnOffChanged;
// Add cell into the table view
sublayersSection.Add(cell);
}
// Add section to the table view
sublayersTableView.Root.Add(sublayersSection);
// Add table to the root layout
layout.Children.Add(sublayersTableView);
// Create internal page for the navigation page
var sublayersPage = new ContentPage()
{
Content = layout,
Title = "Sublayers"
};
// Navigate to the sublayers page
await Navigation.PushAsync(sublayersPage);
}