using System.Windows.Controls; namespace ParasitemiaUIControls { public partial class RBCFrame : UserControl { bool isTextBelow = false; public RBCFrame() { this.InitializeComponent(); this.borderRBCNumber.SizeChanged += BorderRBCNumber_SizeChanged; } public bool IsTextBelow { get => this.isTextBelow; set { if (value != this.isTextBelow) { this.isTextBelow = value; this.UpdateRBCNumberPosition(); } } } void BorderRBCNumber_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e) { this.UpdateRBCNumberPosition(); //this.UpdateLayout(); //System.Diagnostics.Debug.WriteLine($"ActuaSize: {this.borderRBCNumber.ActualHeight}"); } void UpdateRBCNumberPosition() { var m = this.borderRBCNumber.Margin; m.Bottom = this.isTextBelow ? - this.borderRBCNumber.ActualHeight - 0.05 * this.borderRBCNumber.ActualHeight : 0.05 * this.borderRBCNumber.ActualHeight; this.borderRBCNumber.Margin = m; } } }