鼠标悬停在图像标签中放大图像

我有这样的图像:

<Image Height="180" Width="180" Source="{Binding Result}" Grid.Column="1" />

如何在鼠标悬停时放大(缩放)此标签中的图像?尽可能以最简单的方式。我想Image从上面进行编辑。我想放大此标签中的图像并保持此尺寸 ( 180*180)


POPMUISE
浏览 118回答 1
1回答

潇潇雨雨

您可以将 放入Image固定size网格中,ScaleTransform对其应用 a 并对后者进行动画处理。像这样的事情:<Grid Height="180" Width="180">&nbsp; &nbsp; <Image Height="180" Width="180" Source="{Binding Result}" Grid.Column="1">&nbsp; &nbsp; &nbsp; &nbsp; <Image.LayoutTransform>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ScaleTransform x:Name="st" CenterX="90" CenterY="90" ScaleX="1" ScaleY="1" />&nbsp; &nbsp; &nbsp; &nbsp; </Image.LayoutTransform>&nbsp; &nbsp; &nbsp; &nbsp; <Image.Triggers>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <EventTrigger RoutedEvent="Image.MouseEnter">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <EventTrigger.Actions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BeginStoryboard>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Storyboard>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <DoubleAnimation Storyboard.TargetName="st"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Storyboard.TargetProperty="(ScaleTransform.ScaleX)"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;To="3.0" Duration="0:0:0" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <DoubleAnimation Storyboard.TargetName="st"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Storyboard.TargetProperty="(ScaleTransform.ScaleY)"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;To="3.0" Duration="0:0:0" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Storyboard>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </BeginStoryboard>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </EventTrigger.Actions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </EventTrigger>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <EventTrigger RoutedEvent="Image.MouseLeave">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <EventTrigger.Actions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BeginStoryboard>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Storyboard>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <DoubleAnimation Storyboard.TargetName="st"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Storyboard.TargetProperty="(ScaleTransform.ScaleX)"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;To="1.0" Duration="0:0:0" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <DoubleAnimation Storyboard.TargetName="st"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Storyboard.TargetProperty="(ScaleTransform.ScaleY)"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;To="1.0" Duration="0:0:0" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Storyboard>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </BeginStoryboard>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </EventTrigger.Actions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </EventTrigger>&nbsp; &nbsp; &nbsp; &nbsp; </Image.Triggers>&nbsp; &nbsp; </Image></Grid>
打开App,查看更多内容
随时随地看视频慕课网APP