0

私の要件は、2 行のグリッドを持つことです。最初の行には、DB クエリの検索基準としてコンボボックスが入力されます。2 行目は、結果を含む DataGrid になります。

上部のグリッドにカーソルを合わせると上から下にスライドし、マウスを離すと上にスライドするようにします。上部の「フィルター」に単純なテキストブロックを配置し、その上にカーソルを合わせるとコンボボックスがダウンするのではないでしょうか?

私はこのようなものを持っていますが、マウスオーバーするとアニメーションが停止せずに上下します。

    <Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="40"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <Grid Grid.Row="0">
        <Grid.Triggers>
            <EventTrigger RoutedEvent="MouseEnter">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation 
                    Storyboard.TargetName="ControlsGrid" 
                    Storyboard.TargetProperty="(Grid.Height)"
                    From="0" 
                    To="66" 
                    Duration="0:0:0.5" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
            <EventTrigger RoutedEvent="MouseLeave">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation 
                    Storyboard.TargetName="ControlsGrid"
                    Storyboard.TargetProperty="(Grid.Height)"
                    From="66" 
                    To="0" 
                    Duration="0:0:0.5" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Grid.Triggers>

        <TextBlock HorizontalAlignment="Center" FontSize="20" Text="Filters..."/>
    </Grid>

    <Grid Margin="0" Name="ControlsGrid" VerticalAlignment="top" Background="Yellow"/>
    <DataGrid Grid.Row="1" ColumnHeaderStyle="{DynamicResource GridViewColumnHeaderStyle}" Background="LightGray" RowBackground="LightYellow" AlternatingRowBackground="LightBlue" 
              x:Name="dataGridViewRoomQuery"  BorderBrush="Gray" BorderThickness="5"/>

</Grid>
4

1 に答える 1

0

あなたのアプローチの問題は、「ホバリング」グリッド(イベントトリガーのあるもの)がその上に配置さMouseLeaveれるたびにイベントを取得することです。ControlsGrid

ControlsGridをホバリング グリッドに配置する必要があります。

<Grid Grid.Row="0" Background="Transparent">
    <Grid.Triggers>
        <EventTrigger RoutedEvent="MouseEnter">
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetName="ControlsGrid" 
                                        Storyboard.TargetProperty="Height"
                                        To="66" Duration="0:0:0.5" />
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
        <EventTrigger RoutedEvent="MouseLeave">
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetName="ControlsGrid" 
                                        Storyboard.TargetProperty="Height"
                                        To="0" Duration="0:0:0.5" />
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Grid.Triggers>

    <TextBlock HorizontalAlignment="Center" FontSize="20" Text="Filters..."/>

    <Grid Name="ControlsGrid" Height="0" VerticalAlignment="Top" Background="Yellow">
    </Grid>
</Grid>
<DataGrid .../>
于 2013-04-08T06:25:10.057 に答える