WinRT ListView和ExpanderView问题

时间:2014-06-06 00:15:59

标签: windows-runtime winrt-xaml win-universal-app

之后,我认为将Windows Phone工具包ExpanderView成功移植到WinRT,我注意到它不能100%正常工作。

这是我正在尝试做的事情: -

我有一个ListView,其中ItemsSource是数据绑定的,在这个ListView的ItemTemplate里面有一个ExpanderView我端口??? !!!我的想法是,当我点击ListView项目时,我希望展开扩展视图。

这就是说,当ExpanderView扩展时它发生了,它与下一个ListView项重叠,即ListViewItem Height没有改变。为什么我真的不知道。我想出了解决这个问题的每一个可能的想法,但是徒劳无功:(

任何人都可以帮助我并引导我朝着正确的方向前进吗?

下面是一个简单示例(包含所有必要代码的VS项目)的链接,用于演示此问题 Simple Universal App to demo the problem

提前致谢

2 个答案:

答案 0 :(得分:3)

有很多地方有动画可以进行布局更改。这些动画的UI线程很重,因此需要将属性EnableDependentAnimations设置为True。你可以找到更多关于它的信息here。您可能需要进入样式并手动更改VisualStates以进行此更改。一个这样的例子是:

在ExpanderResource.xaml中:

<VisualStateGroup x:Name="ExpansionStates">
    <VisualStateGroup.Transitions>
        <VisualTransition From="Collapsed"
                          GeneratedDuration="0:0:0.15" To="Expanded">
            <Storyboard>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="ItemsCanvas" EnableDependentAnimation="True">
                    <EasingDoubleKeyFrame EasingFunction="{StaticResource QuadraticEaseOut}" KeyTime="0:0:0.00" Value="0" />
                    <EasingDoubleKeyFrame x:Name="CollapsedToExpandedKeyFrame" EasingFunction="{StaticResource QuadraticEaseOut}" KeyTime="0:0:0.15" Value="1" />
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </VisualTransition>
    </VisualStateGroup.Transitions>
</VisualStateGroup>

请注意,DoubleAnimationUsingKeyFrames定位(FrameworkElement.Height)需要EnableDependentAnimations="True",因为这会影响布局。

这不是该文件中唯一需要修复的地方。此外,我认为它不会解决您的所有布局问题。它会让它扩展布局的属性。

答案 1 :(得分:0)

请确保您使用stackpanel作为面板。

<ListView>
    <ListView.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel />
        </ItemsPanelTemplate>
    </ListView.ItemsPanel>
</ListView>

祝你好运!

相关问题