[英]How to make textblock blink|flash in C# for Windows Phone 8.1?
我有一個MainPage.xaml頁面,其中有一個文本框和一個用於page1.xaml轉換的按鈕,在我的頁面mainpage.cs中,我有一個方法:
private void Button_Click(object sender, RoutedEventArgs e)
{
string newUrl = "/Page1.xaml?text=" + textoInput.Text;
NavigationService.Navigate(new Uri(newUrl, UriKind.Relative));
}
在我的Page1.xaml中,我有一個文本塊,它將是MainPage.xaml中放置在文本框中的文本。 在我的Page1.cs中,我有一個方法:
string textBoxValue = "";
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
//Retrieve the value passed during page navigation
NavigationContext.QueryString.TryGetValue("text", out textBoxValue);
textBlockTexto.Text = textBoxValue;
}
我的問題是如何使我的文本塊(text.BlockTexto.Text)無限閃爍
謝謝
您可以將Storyborad
與ColorAnimation
Storyborad
使用。 這是MSDN示例 。
將StackPanel
更改為TextBox
,它將為您設置背景動畫。 這是一個帶有動畫效果的TextBox示例:
<TextBox TextBox_Tap="Textbox_Tapped" Text="MyText">
<TextBox.Resources>
<Storyboard x:Name="myStoryboard">
<!-- Animate the background color of the canvas from red to green over 4 seconds. -->
<ColorAnimation Storyboard.TargetName="mySolidColorBrush"
Storyboard.TargetProperty="Color"
From="Red" To="Green" Duration="0:0:4" />
</Storyboard>
</TextBox.Resources>
<TextBox.Background>
<SolidColorBrush x:Name="mySolidColorBrush" Color="Red" />
</TextBox.Background>
</StackPanel>
如何調用動畫:
// When the user taps the textbox, the animation begins.
private void TextBox_Tap(object sender, System.Windows.Input.GestureEventArgs e){
myStoryboard.Begin();
}
我不建議您無限循環播放動畫,因為這不在設計准則之內,並且由於移動設備的GPU / CPU上的高負荷而消耗了電池。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.