I want to develop an application in WPF, and same in Windows Phone 8.1. Where I want to increase the value of a variable from 100 to 200, from 200 to 300 and go on. This is a score of the game. Now I want to animate this in the UI. I have written a sample code like this.
<Button Click="Button_Click" >Start</Button>
<TextBlock x:Name="tbvalue" />
So when the button is clicked the value will be from 100 to 200, but this should be displayed in the UI like 101,102,103 ... with incremental value animated in the UI.
I have written the code behind like
private void Button_Click(object sender, RoutedEventArgs e)
{
while (count < upperLimit)
{
count += 1;
this.Dispatcher.BeginInvoke(new Action<object>(perform), sender);
System.Threading.Thread.Sleep(100);
}
i++;
upperLimit = i * 100;
}
and in that
private void perform(object obj)
{
tbvalue.Text = count.ToString();
}
But using this I am not achieving the counter animation. any ideas or suggestions how to achieve this functionality.
This is what I did and it is working fine.I made a demo wpf application
Xaml File: