'Couldn't change the ListViewHeader size from ElementCompositionPreview
I expect when user scrolls the ListView, it will reduce the ListViewHeader' height. I have already tried this code, it didn't change anything.
List.xaml:
<ListView x:Name="ListMain" ... >
<ListView.Header>
<Grid x:Name="ListHeader" ... >
<!-- some layouts here -->
</Grid>
<ListView.Header>
</ListView>
List.cs:
Border border = (Border)VisualTreeHelper.GetChild(ListMain, 0);
ScrollViewer scrollViewer = (ScrollViewer)border.Child;
var scrollViewerManipulationPropSet = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scrollViewer);
var scrollPropSet = scrollViewerManipulationPropSet.GetSpecializedReference<ManipulationPropertySetReferenceNode>();
var offsetExpression = -scrollPropSet.Translation.Y + 30;
var sizeExpression = ExpressionFunctions.Clamp(scrollPropSet.Translation.Y, 100, 350);
var targetElement = ElementCompositionPreview.GetElementVisual(ListHeader);
targetElement.StartAnimation("Offset.Y", offsetExpression);
targetElement.StartAnimation("Size.Y", sizeExpression);
Is there something missing here? I couldn't find some clues on Microsoft's documentation.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
