【问题标题】:WinrtTrigger to change grid visibilityWinrtTrigger 更改网格可见性
【发布时间】:2014-03-30 10:53:27
【问题描述】:

我正在使用这个 xaml 来控制加载事件时网格的可见性。

    <Grid Grid.RowSpan="2" x:Name="grdStartup">
        <trigger:Interactions.Triggers>
            <trigger:EventTrigger EventName="Loaded" >                    
                <trigger:SetPropertyAction PropertyName="Visibility" Value="Collapsed"/>
            </trigger:EventTrigger>
        </trigger:Interactions.Triggers>
    </Grid>

这不起作用,没有错误,也没有结果。 现在它已折叠,但稍后我会将它绑定到某个属性。

【问题讨论】:

  • 为什么不直接将其Visibility="Collapsed" 设置为默认值,因为无论如何您都希望它像 onload 一样?触发器似乎是多余的。
  • 我使用折叠只是为了测试。在加载时,我必须将其可见性与 viewmodel 属性绑定。之后,它的可见性由故事板管理。

标签: c# xaml windows-8 triggers


【解决方案1】:

希望这会有所帮助。更多详情Visit

    <Grid x:Name="Gd" Visibility="Visible">
        <Grid.Triggers>
            <EventTrigger>
                <BeginStoryboard>
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Gd" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame Value="Collapsed" KeyTime="0"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Grid.Triggers>
    </Grid>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-04-07
    • 2013-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多