Posts

Showing posts with the label Wpf Grid

Collapse Grid Row In WPF

Answer : All you need is something to cache the height(s) of the visible row. After that, you no longer need converters or to toggle visibility of contained controls. CollapsibleRow public class CollapsibleRow : RowDefinition { #region Fields private GridLength cachedHeight; private double cachedMinHeight; #endregion #region Dependency Properties public static readonly DependencyProperty CollapsedProperty = DependencyProperty.Register("Collapsed", typeof(bool), typeof(CollapsibleRow), new PropertyMetadata(false, OnCollapsedChanged)); private static void OnCollapsedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if(d is CollapsibleRow row && e.NewValue is bool collapsed) { if(collapsed) { if(row.MinHeight != 0) { row.cachedMinHeight = row.MinHeight; row.MinHeight = 0; } ...

Bottom Borders On WPF Grid

Answer : On a Border control You can do BorderThickness="0 0 0 1" to only have a bottom border shown. Top and bottom border thickness of 5, left and right border thickness of 0 BorderThickness="0 5" Top and bottom border thickness of 0, left and right border thickness of 5 BorderThickness="5 0" Border Thickness - Left: 1, Top: 2, Right:3, Bottom: 4 BorderThickness="1 2 3 4" Hope this helps!