Skip to content

Commit

Permalink
feat: Implement SCP.SizesContentToTemplatedParent
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Oct 27, 2023
1 parent d9ff0ad commit 936fb48
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public double VerticalOffset
#endif
// Skipping already declared property ViewportHeight
// Skipping already declared property ViewportWidth
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__NETSTD_REFERENCE__")]
public bool SizesContentToTemplatedParent
{
get
Expand Down Expand Up @@ -71,8 +71,8 @@ public bool CanContentRenderOutsideBounds
typeof(global::Windows.UI.Xaml.Controls.ScrollContentPresenter),
new Windows.UI.Xaml.FrameworkPropertyMetadata(default(bool)));
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__NETSTD_REFERENCE__")]
public static global::Windows.UI.Xaml.DependencyProperty SizesContentToTemplatedParentProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
nameof(SizesContentToTemplatedParent), typeof(bool),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ public object ScrollOwner

private ScrollViewer Scroller => ScrollOwner as ScrollViewer;

#if UNO_HAS_MANAGED_SCROLL_PRESENTER || __WASM__
public static DependencyProperty SizesContentToTemplatedParentProperty { get; } = DependencyProperty.Register(
nameof(SizesContentToTemplatedParent),
typeof(bool),
typeof(ScrollContentPresenter),
new FrameworkPropertyMetadata(false));

public bool SizesContentToTemplatedParent
{
get => (bool)GetValue(SizesContentToTemplatedParentProperty);
set => SetValue(SizesContentToTemplatedParentProperty, value);
}
#endif

public Rect MakeVisible(UIElement visual, Rect rectangle)
{
// Simulate a BringIntoView request
Expand Down Expand Up @@ -136,13 +150,30 @@ protected override Size MeasureOverride(Size availableSize)
.AtMost(maxSize)
.AtLeast(minSize);

bool sizesContentToTemplatedParent = SizesContentToTemplatedParent;

if (ScrollOwner is ScrollViewer scrollViewer)
{
if (sizesContentToTemplatedParent)
{
slotSize = scrollViewer.ViewportMeasureSize;
}
}


if (CanVerticallyScroll)
{
slotSize.Height = double.PositiveInfinity;
if (!sizesContentToTemplatedParent)
{
slotSize.Height = double.PositiveInfinity;
}
}
if (CanHorizontallyScroll)
{
slotSize.Width = double.PositiveInfinity;
if (!sizesContentToTemplatedParent)
{
slotSize.Width = double.PositiveInfinity;
}
}

child.Measure(slotSize);
Expand Down

0 comments on commit 936fb48

Please sign in to comment.