private void Initialize() { _listView = new UITableView(UIScreen.MainScreen.Bounds) { ClipsToBounds = true, ContentMode = UIViewContentMode.ScaleAspectFill, SeparatorStyle = UITableViewCellSeparatorStyle.None, AllowsSelection = false, Bounces = true, TranslatesAutoresizingMaskIntoConstraints = false, AutoresizingMask = UIViewAutoresizing.All, RowHeight = UITableView.AutomaticDimension, EstimatedRowHeight = 100, }; _listView.RegisterClassForCellReuse(typeof(LegendTableViewCell), LegendTableSource.CellId); var source = new LegendTableSource(_datasource); _listView.Source = source; source.CollectionChanged += Source_CollectionChanged; AddSubview(_listView); _listView.LeadingAnchor.ConstraintEqualTo(LeadingAnchor).Active = true; _listView.TopAnchor.ConstraintEqualTo(TopAnchor).Active = true; _listView.TrailingAnchor.ConstraintEqualTo(TrailingAnchor).Active = true; _listView.HeightAnchor.ConstraintEqualTo(HeightAnchor).Active = true; InvalidateIntrinsicContentSize(); }
private void UpdateSublayers(LayerContentViewModel layerContent) { var subLayers = layerContent?.Sublayers; if (subLayers == null) { _listView.Source = null; _listView.ReloadData(); InvalidateIntrinsicContentSize(); return; } var source = new LegendTableSource(new List <LayerContentViewModel>(subLayers)); _listView.Source = source; source.CollectionChanged += (a, b) => InvokeOnMainThread(() => { _listView.ReloadData(); _listView.SetNeedsUpdateConstraints(); _listView.UpdateConstraints(); }); _listView.ReloadData(); _listView.SetNeedsUpdateConstraints(); _listView.UpdateConstraints(); }
private void Refresh() { if (_listView == null) { return; } if ((GeoView as MapView)?.Map == null && (GeoView as SceneView)?.Scene == null) { _listView.Source = null; _listView.ReloadData(); InvalidateIntrinsicContentSize(); return; } ObservableLayerContentList layers = null; if (GeoView is MapView) { layers = new ObservableLayerContentList(GeoView as MapView, ShowLegendInternal) { ReverseOrder = !ReverseLayerOrder, }; } else if (GeoView is SceneView) { layers = new ObservableLayerContentList(GeoView as SceneView, ShowLegendInternal) { ReverseOrder = !ReverseLayerOrder, }; } if (layers == null) { _listView.Source = null; return; } foreach (var l in layers) { if (!(l.LayerContent is Layer)) { continue; } var layer = l.LayerContent as Layer; if (layer.LoadStatus == LoadStatus.Loaded) { l.UpdateLayerViewState(GeoView.GetLayerViewState(layer)); } } ScaleChanged(); SetLayerContentList(layers); var source = new LegendTableSource(layers); _listView.Source = source; source.CollectionChanged += (a, b) => InvokeOnMainThread(() => { _listView.ReloadData(); InvalidateIntrinsicContentSize(); }); _listView.ReloadData(); InvalidateIntrinsicContentSize(); Hidden = false; }