Fix layout issue with ListBox and ListView

This commit is contained in:
Lluis Sanchez 2012-04-03 20:10:19 +02:00
Родитель 77fdb0b1f4
Коммит 8eb79a5812
3 изменённых файлов: 17 добавлений и 6 удалений

Просмотреть файл

@ -105,8 +105,16 @@ namespace Xwt.WPFBackend
// Use the 'widgets' field so we can easily map a control position by looking at 'rects'.
for (int i = 0; i < widgets.Length; i++) {
var element = WidgetBackend.GetFrameworkElement (widgets [i]);
if (!element.IsArrangeValid || force)
element.Arrange (DataConverter.ToWpfRect (rects [i]));
if (!element.IsArrangeValid || force) {
// Measure the widget again using the allocation constraints. This is necessary
// because WPF widgets my cache some measurement information based on the
// constraints provided in the last Measure call (which when calculating the
// preferred size is normally set to infinite.
element.InvalidateMeasure ();
element.Measure (new SW.Size (rects[i].Width, rects[i].Height));
element.Arrange (DataConverter.ToWpfRect (rects[i]));
}
}
}
}

Просмотреть файл

@ -142,6 +142,12 @@ namespace Xwt.WPFBackend
protected override System.Windows.Size MeasureOverride (System.Windows.Size constraint)
{
var s = base.MeasureOverride (constraint);
if (ScrollViewer.GetHorizontalScrollBarVisibility (this) != ScrollBarVisibility.Hidden)
s.Width = 0;
if (ScrollViewer.GetVerticalScrollBarVisibility (this) != ScrollBarVisibility.Hidden)
s.Height = SystemParameters.CaptionHeight;
return Backend.MeasureOverride (constraint, s);
}
}

Просмотреть файл

@ -49,11 +49,8 @@ namespace Xwt.WPFBackend
protected override System.Windows.Size MeasureOverride (System.Windows.Size constraint)
{
// This line is commented because it breaks listview scrolling
// We have to find a solution because the current implementation is not fully correct
// var s = base.MeasureOverride (constraint);
var s = base.MeasureOverride (constraint);
var s = new System.Windows.Size (0, 0);
if (ScrollViewer.GetHorizontalScrollBarVisibility (this) != ScrollBarVisibility.Hidden)
s.Width = 0;
if (ScrollViewer.GetVerticalScrollBarVisibility (this) != ScrollBarVisibility.Hidden)