【发布时间】:2014-01-08 15:45:54
【问题描述】:
您好,我正在使用 WPF 网格来表示数据。 我有一个名为微调器的图像。我想在加载数据(已经完成)以及更新数据时显示微调器。谁能告诉我如何添加触发器,以便微调器在数据源更新或更改时显示?我尝试了 SourceUpdated,但它不是 RoutedEvent。 WPF 新手,如果问题太初学者请见谅。
<UserControl x:Class="My.IGrid.IGridControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<Storyboard x:Key="Spin360" Storyboard.TargetName="Spinner" Storyboard.TargetProperty="RenderTransform.(RotateTransform.Angle)">
<DoubleAnimation From="0" To="360" BeginTime="0:0:0" Duration="0:0:1.0" RepeatBehavior="Forever" />
</Storyboard>
</UserControl.Resources>
<Grid Name="RootGrid">
<Border>
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="LightGray" Offset="0" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
</Border.Background>
<StackPanel Name="SplashPanel" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.ZIndex="0">
<Image Name="Spinner" Source="/My.IGrid;component/Images/spinner.png" Width="32" Height="32" RenderTransformOrigin="0.5, 0.5">
<Image.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource Spin360}" />
</EventTrigger.Actions>
</EventTrigger>
</Image.Triggers>
<Image.RenderTransform>
<RotateTransform Angle="0" />
</Image.RenderTransform>
</Image>
</StackPanel>
</Border>
</Grid>
</UserControl>
【问题讨论】:
标签: wpf