문제

목록보기가 있습니다.

<ListView Name="myListVew" MaxHeight="200" Visibility="Collapsed">
    <ListView.View>
        <GridView>
            <GridViewColumn Header="Line" Width="Auto" DisplayMemberBinding="{Binding Line}" />
            <GridViewColumn Header="Error" Width="Auto" DisplayMemberBinding="{Binding Error}" />
        </GridView>
    </ListView.View>
</ListView>

ListView가 나타나기를 원할 때 0에서 목록보기의 높이를 애니메이션하고 싶다. 어쨌든이 일이 있습니까?

도움이 되었습니까?

해결책

솔루션을 위해 시간을 검색하고 포럼에 질문을 게시 한 다음 10 분 후에 답을 찾을 때 싫어하지 않습니까?

어쨌든, 나는 그렇게처럼 레이아웃 스케일 변환을 적용하여 작동했습니다.

<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ErrorDisplay" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
    <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>
</DoubleAnimationUsingKeyFrames>

다른 팁

이것은 정확히 같은 시나리오는 아니지만 다른 사람에게 도움이 될 수 있습니다.

나는 자동차의 높이가있는 테두리가 있었고 특정 높이에 애니메이션을 원했습니다.

내 국경은 다음과 같습니다.

<Border Name="ContainerBorder">
  <!-- Stuff... -->
</Border>

이 스토리 보드를 만들었습니다.

<Storyboard x:Key="EditIn">
  <DoubleAnimation Storyboard.TargetProperty="Height"
                   Storyboard.TargetName="ContainerBorder"
                   Name="BorderAnimation"
                   To="45"
                   Duration="0:0:0.8" />
</Storyboard>

애니메이션을 트리거 한 버튼에는 코드가 있습니다.

private void Edit_Click(object sender, RoutedEventArgs e) {
  Storyboard sb = (Storyboard)FindResource("EditIn");
  //Find the border animation
  DoubleAnimation da = (DoubleAnimation)sb.Children.Where(t => t.Name == "BorderAnimation").FirstOrDefault();
  if (da != null) { da.From = ContainerBorder.ActualHeight; }
  sb.Begin(this);
}

그래서 나는 단순히 테두리를 찾아 애니메이션의 "속성"을 프레임 워크 엘레멘트의 실제 보상으로 설정했습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top