听说我正在ObservableCollection
用一些时间间隔将一些数据绑定到我的文本块我正在显示没有任何动画的数据,但我需要动画才能显示。这是我的代码:
DispatcherTimer timer = new DispatcherTimer();
public ObservableCollection<ItemViewModel> Items { get; private set; }
public Slideshow()
{
InitializeComponent();
this.Items = new ObservableCollection<ItemViewModel>();
DataContext = App.ViewModel;
this.Items = App.ViewModel.Items;
}
private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
{
itemNumber = 0;
Name.Text = this.Items[itemNumber].LineOne;
if (!App.ViewModel.IsDataLoaded)
{
App.ViewModel.LoadData();
}
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(5);
timer.Tick += new EventHandler(timer_Tick);
itemNumber++;
timer.Start();
}
public void timer_Tick(object sender, EventArgs e)
{
if (this.Items.Count > 0)
{
itemNumber++;
Name.Text = this.Items[itemNumber].LineOne;
if (itemNumber == this.Items.Count)
itemNumber = 0;
}
}
XAML 代码
<TextBlock x:Name="Name" Foreground="White" Text="{Binding LineOne}"/>
我该怎么做。提前致谢