3

For instance I am setting the Visibility on and off for a certain element. I have a Trigger that listens to the Visibility being set to Visible and plays out a Storyboard that fades in the element.

So on the flip side, when the element is set to Hidden, I want the element to fade out, and then have the property set to Visibility = false. Is this possible and if so how? Currently I have something like:

    <Style.Triggers>
        <Trigger Property="Visibility" Value="Visible">
            <Trigger.EnterActions>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.5" />
                    </Storyboard>
                </BeginStoryboard>
            </Trigger.EnterActions>
            <Trigger.ExitActions>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="0:0:0.5" />
                    </Storyboard>
                </BeginStoryboard>
            </Trigger.ExitActions>
        </Trigger>
    </Style.Triggers>
4

1 回答 1

2

有更多的 Trigger 类让人眼前一亮。也许你可以使用另一个触发器来实现你想做的事情。

来自 MSDN:

有几种不同类型的触发器:TriggerMultiTriggerEventTriggerDataTriggerMultiDataTrigger

也许使用 DataTrigger 绑定到状态属性,告诉 UI 正在发生变化?或者您可以尝试使用自定义事件和 EventTrigger 来实现相同的目的?只是一些想法..

于 2009-07-28T15:18:50.223 回答