WPF新手。
我试图围绕XAML语法,但这只是几天。我想知道如何将MouseOver效果(特别是阴影)应用于此代码块中的所有Image标记:
<ScrollViewer VerticalScrollBarVisibility="Auto">
<WrapPanel Orientation="Horizontal">
<WrapPanel.Style>
<Style>
</Style>
</WrapPanel.Style>
<Image Source="../Image.jpg" Width="200" Height="296" Margin="0,10,10,10"/>
<Image Source="../Image.jpg" Width="200" Height="296" Margin="10,10,10,10"/>
<Image Source="../Image.jpg" Width="200" Height="296" Margin="10,10,10,10"/>
<Image Source="../Image.jpg" Width="200" Height="296" Margin="10,10,0,10"/>
</WrapPanel>
</ScrollViewer>
答案 0 :(得分:0)
这将应用DropShadowEffect:
<ScrollViewer VerticalScrollBarVisibility="Auto">
<WrapPanel Orientation="Horizontal">
<WrapPanel.Resources>
<Style TargetType="Image">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect />
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</WrapPanel.Resources>
<WrapPanel.Style>
<Style>
</Style>
</WrapPanel.Style>
<Image Source="/Image.jpg" Width="200" Height="296" Margin="0,10,10,10"/>
<Image Source="/Image.jpg" Width="200" Height="296" Margin="10,10,10,10"/>
<Image Source="/Image.jpg" Width="200" Height="296" Margin="10,10,10,10"/>
<Image Source="/Image.jpg" Width="200" Height="296" Margin="10,10,0,10"/>
</WrapPanel>
</ScrollViewer>