I solved this problem by using the Dispatcher:
private void grid_SizeChanged(object sender, SizeChangedEventArgs e)
{
//text.Text = grid.Width.ToString();
Dispatcher.BeginInvoke(new Action(() => text.Text = grid.Width.ToString()));
}
Thank you all for “help” and negative rating.
solved .NET bug. How to fix?