开发者

Assigning DependencyProperty runs slow

There is Button button1 and TextBox textBox1. Here's button1's ClickEvent hadler:

priv开发者_如何学Pythonate void button1_Click(object sender, RoutedEventArgs e)
{
    DateTime now = DateTime.Now;
    textBox1.Text = "some text";
    TimeSpan span = DateTime.Now - now;
    MessageBox.Show(span.TotalMilliseconds.ToString());
}            

span.TotalMilliseconds is 1...2 in Debug and 0...1 in Release. But even in Release it has value of "0" only in about 2 times of 10.

Question is, why is it so slow?

I am implementing my own control similar to DataGrid and I have about 300 visible cells on screen. I implemented my own UI virtualization that is based on moving data "behind" the cells. So every time I scroll each cell's text gets updated. And it lasts more than 300 milliseconds.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜