我正在开发一个Windows Phone 7.1应用程序,我需要设置搜索文本框(toolkit:PhoneTextBox
)的动画,就像人们应用程序中发生的那样。成为Visible
后从屏幕顶部滑入,然后在Collapsed
上滑出。
我在网上搜索资源但没找到任何资源。
编辑:我启动动画的代码。幻灯片在工作中,我尝试滑出同样的,它没有。
void SearchBox_Click(object sender, System.EventArgs e)
{
{
if (SearchBox.Visibility == System.Windows.Visibility.Collapsed)
{
(this.Resources["ShowSearchTextbox"] as Storyboard).Begin();
SearchBox.Focus();
SearchBox.Visibility = System.Windows.Visibility.Visible;
SearchBox.Foreground = new SolidColorBrush(Colors.Gray);
}
else
{
SearchFilter.Instance.SearchText = String.Empty;
SearchBox.Text = string.Empty;
(this.Resources["HideSearchTextbox"] as Storyboard).Begin();
SearchBox.Visibility = System.Windows.Visibility.Collapsed;
}
}
}
答案 0 :(得分:2)
您可以使用故事板:
<Storyboard x:Key="showsearchtextbox">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" Storyboard.TargetName="searchtextbox">
<DiscreteDoubleKeyFrame KeyTime="0" Value="-100"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.500" Value="0">
<EasingDoubleKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
使用以下TextBox:
<TextBlock x:Name="searchtextbox">
<TextBlock.RenderTransform>
<TranslateTransform Y="-100"/>
</TextBlock.RenderTransform>
</TextBlock>
然后当用户按下搜索图标时:
(this.Resources["showsearchtextbox"] as Storyboard).Begin();
searchtextbox.Focus();