Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xaml 在“时隐藏元素”;ImageBrush";图像无法加载_Xaml_Silverlight_Windows Phone 8_Windows Phone - Fatal编程技术网

Xaml 在“时隐藏元素”;ImageBrush";图像无法加载

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

我正在使用带有ImageBrush的OpacityMask,并希望在图像无法加载的情况下隐藏元素。我尝试使用EventTrigger,但这是

        <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}”
确实有效