private void Reset() { _keys = null; Children.Clear(); RowDefinitions.Clear(); ColumnDefinitions.Clear(); }
public AccordionGrid() { HorizontalOptions = LayoutOptions.FillAndExpand; HeightRequest = 60; ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(45) }); ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(30) }); RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) }); RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1) }); }
private void AddItems(IList items) { foreach (var item in items) { if (Children.Count > 0) { RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); var gridSplitter = new GridSplitter { Height = 5, Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Stretch, }; SetRow(gridSplitter, Children.Count); Children.Add(gridSplitter); } RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star), MinHeight = 40, }); var contentPresenter = new ContentPresenter(); contentPresenter.SetValue(ContentPresenter.ContentTemplateProperty, ItemTemplate); contentPresenter.Content = item; SetRow(contentPresenter, Children.Count); Children.Add(contentPresenter); } }
private void BuildTiles() { // Wipe out the previous row & Column definitions if they're there. if (RowDefinitions.Any()) { RowDefinitions.Clear(); } BuildColumns(); Children.Clear(); var tiles = ItemsSource; if (tiles != null) { var numberOfRows = Math.Ceiling(tiles.Count / (float)MaxColumns); for (var i = 0; i < numberOfRows; i++) { RowDefinitions.Add(new RowDefinition { Height = 200f }); } for (var index = 0; index < tiles.Count; index++) { var column = index % MaxColumns; var row = (int)Math.Floor(index / (float)MaxColumns); var tile = BuildTile(tiles[index]); Children.Add(tile, column, row); } } }
public MultiColumnFlowGrid(int num_columns, double spacing) { this.num_columns = num_columns; this.spacing = spacing; // Add the column definitions for (int i = 0; i < num_columns; ++i) { if (0 != i && 0 != spacing) { ColumnDefinition cd = new ColumnDefinition(); cd.Width = new GridLength(spacing); ColumnDefinitions.Add(cd); } { ColumnDefinition cd = new ColumnDefinition(); cd.Width = new GridLength(1, GridUnitType.Star); ColumnDefinitions.Add(cd); } } // Add the first row RowDefinitions.Add(new RowDefinition()); }
protected override void OnSizeAllocated(double width, double height) { base.OnSizeAllocated(width, height); if (RowDefinitions.Count == 0 && ColumnDefinitions.Count == 0 && width != -1 && height != -1) { for (var i = 0; i < MaxColumns; i++) { try { if (Math.Abs(TileHeight) < 0.01) { RowDefinitions.Add(new RowDefinition() { Height = new GridLength(width / MaxColumns) }); } else { RowDefinitions.Add(new RowDefinition() { Height = TileHeight }); } ColumnDefinitions.Add(new ColumnDefinition()); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } } } }
private void UpdateRowsAndColumns() { if (_prices != null && _currency != null) { Children.Clear(); RowDefinitions.Clear(); for (int i = 0; i < _prices.Count; i++) { var price = _prices[i]; var label = new TextBlock(); label.Style = App.Current.Resources["DisabledBodyTextBlockStyle"] as Style; label.Text = price.Label; label.Margin = new Thickness(12, 4, 0, 4); var amount = new TextBlock(); amount.Style = App.Current.Resources["DisabledBodyTextBlockStyle"] as Style; amount.Text = BindConvert.Current.FormatAmount(price.Amount, _currency); amount.Margin = new Thickness(8, 4, 12, 4); amount.TextAlignment = TextAlignment.Right; Grid.SetRow(label, i); Grid.SetRow(amount, i); Grid.SetColumn(amount, 1); Children.Add(label); Children.Add(amount); RowDefinitions.Add(new RowDefinition { Height = new GridLength(0, GridUnitType.Auto) }); } } }
private void UpdateRowDefinitions() { int lastColumn = -1; int currentRow = -1; foreach (UIElement child in InternalChildren) { int childColumn = GetColumn(child); if (childColumn <= lastColumn || lastColumn == -1) { currentRow++; if (RowDefinitions.Count < currentRow + 1) { RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); } } lastColumn = childColumn; SetRow(child, currentRow); FrameworkElement control = child as FrameworkElement; if (control != null) { control.VerticalAlignment = VerticalAlignment.Center; } } }
private void UpdateRowsAndColumns() { if (_options != null && _currency != null) { Children.Clear(); RowDefinitions.Clear(); Shipping = _options[0]; for (int i = 0; i < _options.Count; i++) { var option = _options[i]; var radio = new RadioButton(); radio.IsChecked = i == 0; radio.Content = BindConvert.Current.ShippingOption(option, _currency); radio.Margin = new Thickness(12, 4, 12, 4); radio.DataContext = option; radio.Checked += (s, args) => { Shipping = radio.DataContext as ShippingOption; }; Grid.SetRow(radio, i); Children.Add(radio); RowDefinitions.Add(new RowDefinition { Height = new GridLength(0, GridUnitType.Auto) }); } } }
// Used to interleave specified row dimensions with automatic rows added to use // underlying Grid layout for main arrange of UniformGrid. internal void SetupRowDefinitions(int rows) { // Mark initial definitions so we don't erase them. foreach (var rd in RowDefinitions) { if (GetAutoLayout(rd) == null) { SetAutoLayout(rd, false); } } // Remove non-autolayout rows we've added and then add them in the right spots. if (rows != RowDefinitions.Count) { for (int r = RowDefinitions.Count - 1; r >= 0; r--) { if (GetAutoLayout(RowDefinitions[r]) == true) { RowDefinitions.RemoveAt(r); } } for (int r = this.RowDefinitions.Count; r < rows; r++) { var rd = new RowDefinition(); SetAutoLayout(rd, true); this.RowDefinitions.Insert(r, rd); } } }
//helper method for laying out all elements in the view grid private void SetupView() { HorizontalOptions = LayoutOptions.FillAndExpand; HeightRequest = 100; RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(20) }); Children.Add(time, 0, 0); Children.Add(date, 0, 1); Children.Add(close, 1, 0); SetRowSpan(close, 2); }
public void UpdateAccordionLayout() { RowDefinitions.Clear(); ColumnDefinitions.Clear(); int i = 0; foreach (UIElement child in Children) { if (child is AccordionItem && !(child as AccordionItem).IsExpanded) { ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); } else { ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); } Grid.SetColumn(child, i); i++; } InvalidateMeasure(); }
public TealTemplate() { RowDefinitions.Add(new RowDefinition { Height = new GridLength(0.1, GridUnitType.Star) }); RowDefinitions.Add(new RowDefinition { Height = new GridLength(0.8, GridUnitType.Star) }); RowDefinitions.Add(new RowDefinition { Height = new GridLength(0.1, GridUnitType.Star) }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.05, GridUnitType.Star) }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.95, GridUnitType.Star) }); var topBoxView = new BoxView { Color = Color.DarkGray }; Children.Add(topBoxView, 0, 0); Grid.SetColumnSpan(topBoxView, 2); }
public DateGrid() { ColumnSpacing = 7; RowSpacing = 7; HorizontalOptions = LayoutOptions.FillAndExpand; VerticalOptions = LayoutOptions.FillAndExpand; RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); }
public void BindGridStructure() { RowDefinitions.Clear(); ColumnDefinitions.Clear(); Observable.Range(0, Rows) .Subscribe(c => { var rowDef = new RowDefinition(); if (CellHeight > 0) { rowDef.Height = new GridLength(CellHeight); } RowDefinitions.Add(rowDef); }); Observable.Range(0, Columns) .Subscribe(c => { var def = new ColumnDefinition(); if (CellWidth > 0) { def.Width = new GridLength(CellWidth); } ColumnDefinitions.Add(def); }); }
public ButtonGrid(UIElement icon, string text) { RowDefinitions.Add(new RowDefinition()); RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); ColumnDefinitions.Add(new ColumnDefinition()); this.textBlock = new TextBlock() { Text = text, HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(4, 0, 4, 0) }; Grid.SetRow(textBlock, 1); IsChecked = false; selection.Fill = new SolidColorBrush(Color.FromArgb(255, 150, 210, 255)); selection.HorizontalAlignment = HorizontalAlignment.Stretch; selection.VerticalAlignment = VerticalAlignment.Stretch; Grid.SetRowSpan(selection, 2); Children.Add(selection); Children.Add(iconHolder); iconHolder.VerticalAlignment = VerticalAlignment.Center; iconHolder.HorizontalAlignment = HorizontalAlignment.Center; iconHolder.Margin = new Thickness(4, 4, 4, 0); this.Icon = icon; textBlock.FontSize = Settings.DefaultToolbarFontSize; Children.Add(textBlock); }
protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved) { base.OnVisualChildrenChanged(visualAdded, visualRemoved); int curRow = -1; int curCol = 0; RowDefinitions.Clear(); if (Children != null) { foreach (UIElement curChild in Children) { if (curCol == 0) { RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); curRow += 1; } Grid.SetRow(curChild, curRow); Grid.SetColumn(curChild, curCol); curCol += 1; if (curCol == 2) { curCol = 0; } } } }
private void UpdateChildren() { var alreadyContainedChildren = Children.OfType <ILayoutControl>().ToArray(); DetachOldSplitters(); DetachPropertyChangeHandler(); Children.Clear(); ColumnDefinitions.Clear(); RowDefinitions.Clear(); var manager = _model?.Root?.Manager; if (manager == null) { return; } foreach (var child in _model.Children) { var foundContainedChild = alreadyContainedChildren.FirstOrDefault(chVM => chVM.Model == child); if (foundContainedChild != null) { Children.Add(foundContainedChild as UIElement); } else { Children.Add(manager.CreateUIElementForModel(child)); } } CreateSplitters(); UpdateRowColDefinitions(); AttachNewSplitters(); AttachPropertyChangeHandler(); }
void updateGridDimensions() { if (ColumnWidth < 0 || RowHeight < 0) { return; } ColumnDefinitions.Clear(); RowDefinitions.Clear(); for (int i = 0; i < ColumnCount; i++) { ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(ColumnWidth) }); } for (int i = 0; i < RowCount; i++) { RowDefinitions.Add(new RowDefinition() { Height = new GridLength(RowHeight) }); } System.Threading.Thread.Sleep(20); reArrangItems(); }
public LabelValuePanel() { ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(6) }); ColumnDefinitions.Add(new ColumnDefinition()); Loaded += delegate { Enumerable .Range(1, (Children.Count / 2)) .Apply(x => RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto })); for (var index = 0; index < Children.Count; index++) { var row = index / 2; var col = (index % 2 == 1) ? 2 : 0; var child = (FrameworkElement)Children[index]; SetColumn(child, col); SetRow(child, row); } }; }
private void AddRows(int count) { RowDefinitions.Clear(); RowDefinition firstRow = new RowDefinition(); firstRow.Height = new GridLength(1, GridUnitType.Star); RowDefinitions.Add(firstRow); for (int i = 0; i < count; i++) { RowDefinition spaceBetween = new RowDefinition(); spaceBetween.Height = new GridLength(20); RowDefinitions.Add(spaceBetween); RowDefinition cards = new RowDefinition(); cards.Height = GridLength.Auto; RowDefinitions.Add(cards); } RowDefinition lastSpaceBetween = new RowDefinition(); lastSpaceBetween.Height = new GridLength(20); RowDefinitions.Add(lastSpaceBetween); RowDefinition lastRow = new RowDefinition(); lastRow.Height = new GridLength(1, GridUnitType.Star); RowDefinitions.Add(lastRow); }
private void Populate(InstanceRuntimeDetails runtimeDetails) { Children.Clear(); RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); var header = new Label(); header.Text = runtimeDetails.Name; header.FontSize = 18; header.Margin = new Thickness(5, 0, 5, 0); header.SetValue(Grid.ColumnSpanProperty, 4); header.FontAttributes = FontAttributes.Bold; Children.Add(header); RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); var statusLabelSection = new StackLayout(); statusLabelSection.Orientation = StackOrientation.Horizontal; statusLabelSection.SetValue(Grid.ColumnSpanProperty, 4); statusLabelSection.SetValue(Grid.RowProperty, RowDefinitions.Count - 1); var statusLabel = new Label(); statusLabel.Text = "Status:"; statusLabel.FontSize = 16; statusLabel.Margin = new Thickness(5, 0, 5, 0); statusLabel.FontAttributes = FontAttributes.Bold; statusLabelSection.Children.Add(statusLabel); var label = new Label(); label.Text = runtimeDetails.Status.ToString(); label.FontSize = 16; statusLabelSection.Children.Add(label); Children.Add(statusLabelSection); AddSectionHeader(5, "fa-headphones", PlatformManagerResources.InstanceDetails_Listeners); foreach (var listener in runtimeDetails.Listeners) { AddItem(30, listener.Name, listener.Status.ToString(), listener.ListenerType, LISTENER_TYPE, listener.Id); } AddSectionHeader(5, "fa-share-alt", PlatformManagerResources.InstanceDetails_Planner); AddItem(30, runtimeDetails.Planner.Name, runtimeDetails.Planner.Status.ToString(), "", PLANNER_TYPE, runtimeDetails.Planner.Id); foreach (var deviceConfig in runtimeDetails.DeviceConfigurations) { AddDeviceConfiguration(deviceConfig); } }
public RungUI AddRow(int pos) { var row = new RowDefinition(); row.Height = GridLength.Auto; RowDefinitions.Insert(pos, row); return(this); }
//This sector contains all the functions that insert a component in the rung #region Help Function public RungUI AddRow() { var row = new RowDefinition(); row.Height = GridLength.Auto; RowDefinitions.Add(row); return(this); }
private void ResetGrid() { Children.Clear(); RowDefinitions.Clear(); _populatingRow = 0; _selectedTrackRow = -1; _justClickedTrack = false; }
public BandedViewBehavior() { #if !SILVERLIGHT TemplatesContainer = new TemplatesContainer(); #endif ColumnDefinitions = new ColumnDefinitions(); RowDefinitions = new RowDefinitions(); }
/// <summary> /// Initializes a new instance of the <see cref="T:XCC.DemoApp.Controls.ResponsiveGrid"/> class. /// </summary> public ResponsiveGrid() { RowDefinitions.Add(new RowDefinition()); RowDefinitions.Add(new RowDefinition()); ColumnDefinitions.Add(new ColumnDefinition()); ColumnDefinitions.Add(new ColumnDefinition()); }
public OnVisualChildrenChangedGrid() { ShowGridLines = true; RowDefinitions.Add(new RowDefinition()); set_called = true; Arrange(new Rect(0, 0, 100, 100)); Assert.AreEqual(calls, 1); }
public CarouselIndicators() { HorizontalOptions = LayoutOptions.CenterAndExpand; RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); Children.Add(_indicators); }
public ZXingScanOverlay(ZXingScanOverlayOptions options = null) { Options = options ?? new ZXingScanOverlayOptions(); RowSpacing = 0; ColumnSpacing = 0; VerticalOptions = FillAndExpand; HorizontalOptions = FillAndExpand; RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); RowDefinitions.Add(new RowDefinition { Height = Options.ScanHeight }); RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); ColumnDefinitions.Add(new ColumnDefinition { Width = Options.ScanWidth }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); AddScreenArea(); AddCenterArea(); SetRow(Options.TopLabel, 0); SetColumnSpan(Options.TopLabel, 3); Children.Add(Options.TopLabel); SetRow(Options.BottomLabel, 2); SetColumnSpan(Options.BottomLabel, 3); Children.Add(Options.BottomLabel); var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.Tapped += (sender, e) => { Options.FlashTappedAction?.Invoke(); }; Options.FlashLabel.GestureRecognizers.Add(tapGestureRecognizer); if (Options.ShowFlash) { Children.Add(Options.FlashLabel, 2, 2); } }
public void Horizontal_Stays_Within_Constraints() { var cursorFactoryImpl = new Mock<IStandardCursorFactory>(); PerspexLocator.CurrentMutable.Bind<IStandardCursorFactory>().ToConstant(cursorFactoryImpl.Object); var control1 = new Border { [Grid.RowProperty] = 0 }; var splitter = new GridSplitter { Orientation = Orientation.Horizontal, [Grid.RowProperty] = 1, }; var control2 = new Border { [Grid.RowProperty] = 2 }; var rowDefinitions = new RowDefinitions() { new RowDefinition(1, GridUnitType.Star) {MinHeight = 70, MaxHeight = 110}, new RowDefinition(GridLength.Auto), new RowDefinition(1, GridUnitType.Star) { MinHeight = 10, MaxHeight = 140}, }; var grid = new Grid() { RowDefinitions = rowDefinitions, Children = new Controls() { control1, splitter, control2 } }; var root = new TestRoot { Child = grid }; Assert.Equal(splitter.Orientation, Orientation.Horizontal); root.Measure(new Size(100, 200)); root.Arrange(new Rect(0, 0, 100, 200)); splitter.RaiseEvent(new VectorEventArgs { RoutedEvent = Thumb.DragDeltaEvent, Vector = new Vector(0, -100) }); Assert.Equal(rowDefinitions[0].Height, new GridLength(70, GridUnitType.Star)); Assert.Equal(rowDefinitions[2].Height, new GridLength(130, GridUnitType.Star)); splitter.RaiseEvent(new VectorEventArgs { RoutedEvent = Thumb.DragDeltaEvent, Vector = new Vector(0, 100) }); Assert.Equal(rowDefinitions[0].Height, new GridLength(110, GridUnitType.Star)); Assert.Equal(rowDefinitions[2].Height, new GridLength(90, GridUnitType.Star)); }
public void Horizontal_Stays_Within_Constraints() { var control1 = new Border { [Grid.RowProperty] = 0 }; var splitter = new GridSplitter { [Grid.RowProperty] = 1, }; var control2 = new Border { [Grid.RowProperty] = 2 }; var rowDefinitions = new RowDefinitions() { new RowDefinition(1, GridUnitType.Star) { MinHeight = 70, MaxHeight = 110 }, new RowDefinition(GridLength.Auto), new RowDefinition(1, GridUnitType.Star) { MinHeight = 10, MaxHeight = 140 }, }; var grid = new Grid() { RowDefinitions = rowDefinitions, Children = new Controls() { control1, splitter, control2 } }; var root = new TestRoot { Child = grid }; root.Measure(new Size(100, 200)); root.Arrange(new Rect(0, 0, 100, 200)); splitter.RaiseEvent(new VectorEventArgs { RoutedEvent = Thumb.DragDeltaEvent, Vector = new Vector(0, -100) }); Assert.Equal(rowDefinitions[0].Height, new GridLength(70, GridUnitType.Star)); Assert.Equal(rowDefinitions[2].Height, new GridLength(130, GridUnitType.Star)); splitter.RaiseEvent(new VectorEventArgs { RoutedEvent = Thumb.DragDeltaEvent, Vector = new Vector(0, 100) }); Assert.Equal(rowDefinitions[0].Height, new GridLength(110, GridUnitType.Star)); Assert.Equal(rowDefinitions[2].Height, new GridLength(90, GridUnitType.Star)); }