【发布时间】:2020-12-11 23:24:48
【问题描述】:
我正在使用 Rotate from 方法
using Microsoft.Toolkit.Uwp.UI.Animations;
旋转 UIElement
但是这种方法不能正常工作。旋转元素,但改变高度和宽度。 我的xml代码:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Click="Button_Click"
Content="Click"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
<ScrollViewer Height="150"
Width="200"
Grid.Row="1"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto">
<Image x:Name="myImage"
Source="/Images/TestImage.png" />
</ScrollViewer>
</Grid>
转法:
int Pos = 0;
private async void Button_Click(object sender, RoutedEventArgs e)
{
Pos = --Pos;
await myImage.Rotate(duration: 0, delay: 1,
centerX: (float)myImage.ActualWidth / 2,
centerY: (float)myImage.ActualHeight / 2,
value: Pos * 90).StartAsync();
}
UIElement 的一部分没有显示(剪辑),因此无法滚动整个元素。
如何旋转元素以改变其尺寸?
【问题讨论】: