Xaml 在“时隐藏元素”;ImageBrush";图像无法加载
我正在使用带有ImageBrush的OpacityMask,并希望在图像无法加载的情况下隐藏元素。我尝试使用EventTrigger,但这是Xaml 在“时隐藏元素”;ImageBrush";图像无法加载,xaml,silverlight,windows-phone-8,windows-phone,Xaml,Silverlight,Windows Phone 8,Windows Phone,我正在使用带有ImageBrush的OpacityMask,并希望在图像无法加载的情况下隐藏元素。我尝试使用EventTrigger,但这是 <Rectangle x:Name="imageRoot" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="{StaticResource PhoneForegroundBru
<Rectangle x:Name="imageRoot"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Fill="{StaticResource PhoneForegroundBrush}"
>
<Rectangle.OpacityMask>
<ImageBrush ImageSource="{Binding ImagePath}" Stretch="Uniform">
<i:Interaction.Triggers>
<i:EventTrigger EventName="ImageFailed">
<ei:ChangePropertyAction PropertyName="Visibility"
TargetName="imageRoot">
<ei:ChangePropertyAction.Value>
<Visibility>Collapsed</Visibility>
</ei:ChangePropertyAction.Value>
</ei:ChangePropertyAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</ImageBrush>
</Rectangle.OpacityMask>
</Rectangle>
崩溃
这似乎只是默默地失败了:没有编译时错误,也没有运行时错误,也没有绑定错误,但是元素没有崩溃。出于某种原因,“TargetName=imageRoot”无法将操作绑定到元素。但是,使用TargetObject=“{Binding ElementName=imageRoot}”
确实有效