[R2D] Reimplemented UI layout engine using WPF's Measure & Arrange pattern