连续显示弹出窗口?

时间:2016-08-31 12:41:39

标签: c# wpf mahapps.metro

我在ListView中有一个内容列表,每个项目都包含一个id,这个id将传递给一个事件,该事件应该显示在Flyout内部点击的行的详细信息。现在我遇到了这种情况:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="5" x:Name="FlyoutRow"/>
    </Grid.RowDefinitions>

所以你如何在主网格中看到我定义了一个名为row的{​​{1}},这一行在启动时是不可见的,但只有当用户点击{{1}中的事件时才会看到1}}。

现在问题是行高为5因此FlyoutRow永远不会出现给用户,是否可以展开保持ListView动画的行?

这是我对Flyout

的实现
Flyout

1 个答案:

答案 0 :(得分:0)

将行高设置为自动。然后使用会导致弹出高度的故事板。

    <Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApplication1"
        xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">

    <Window.Resources>
        <Storyboard x:Key="Maximize">
            <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetProperty="Height" From="5" To="100" Storyboard.TargetName="FL">
            </DoubleAnimation>
        </Storyboard>

        <Storyboard x:Key="Minimize">
            <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetProperty="Height" From="100" To="5" Storyboard.TargetName="FL">
            </DoubleAnimation>
        </Storyboard>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="292*"/>
            <RowDefinition Height="Auto" x:Name="FlyoutRow"/>
        </Grid.RowDefinitions>
        <ListView x:Name="View">
            <ListView.Triggers>
                <EventTrigger RoutedEvent="ListView.SelectionChanged">
                    <BeginStoryboard Storyboard="{StaticResource Maximize}"/>
                </EventTrigger>
                <EventTrigger RoutedEvent="ListView.LostFocus">
                    <BeginStoryboard Storyboard="{StaticResource Minimize}"/>
                </EventTrigger>
            </ListView.Triggers>
            <ListBoxItem Content="First item" Tag="Some information from first item"/>
            <ListBoxItem Content="Second item" Tag="Some information from second item"/>
            <ListBoxItem Content="Third item" Tag="Some information from third item"/>
            <ListBoxItem Content="Fourth item" Tag="Some information from fourth item"/>
            <ListBoxItem Content="Fifth item" Tag="Some information from fifth item"/>
            <ListBoxItem Content="Sixth item" Tag="Some information from sixth item"/>
            <ListBoxItem Content="Seventh item" Tag="Some information from Seventh item"/>
            <ListBoxItem Content="Eigth item" Tag="Some information from eith item"/>
        </ListView>
        <controls:Flyout Grid.Row="1" Width="517" x:Name="FL" HorizontalContentAlignment="Stretch" IsOpen="True">
            <TextBlock Text="{Binding ElementName=View, Path=SelectedItem.Tag}" Background="#FF74FF24"/>
        </controls:Flyout>
    </Grid>
</Window>