I'm working on a document viewer for a WinUI application.
In general it works, except that the scroll viewer height does not change.
So when zooming in the image, the scroll viewer does not change and so the image can't be scrolled to vertical end.
Do you have an idea or solution to that issue ?
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- Image -->
<ScrollViewer
Grid.Row="1"
PointerWheelChanged="ZoomByMouseWheel"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<Image
Height="Auto"
x:Name="PreviewImage"
RenderTransformOrigin="0.5,0.5">
<ui:Effects.Shadow>
<media:AttachedCardShadow Offset="4" CornerRadius="0"/>
</ui:Effects.Shadow>
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="0.01" ScaleY="0.01" />
<ScaleTransform>
<ScaleTransform.ScaleX>
<Binding
ElementName="ZoomSlider"
Mode="OneWay"
Path="Value" />
</ScaleTransform.ScaleX>
<ScaleTransform.ScaleY>
<Binding
ElementName="ZoomSlider"
Mode="OneWay"
Path="Value" />
</ScaleTransform.ScaleY>
</ScaleTransform>
</TransformGroup>
</Image.RenderTransform>
</Image>
</ScrollViewer>
The
ScrollViewerhas its own zooming feature. This is the minimal code that works:MainPage.xaml
MainPage.xaml.cs