[英]WPF SizeChanged event doesn't fire
This is a bit of a noob question. 这是一个小问题。
Basically, I have a grid MainGrid
in my WPF window 基本上,我的WPF窗口中有一个网格
MainGrid
I'd simply like to be notified when the MainGrid
is resized ( when user maximizes/resizes the window). 我只是希望在调整
MainGrid
大小时(当用户最大化/调整窗口大小时)收到通知。
This does nothing at the moment. 目前这没什么。 Am I supposed to declare and then add this SizeChanged event earlier before it will work?
我应该声明然后在它工作之前添加这个SizeChanged事件吗?
private void MainGrid_SizeChanged(object sender, SizeChangedEventArgs e)
{
MyTextBox.Text = "MainGrid resized";
}
Thank you 谢谢
If you have your event in code-behind and this in XAML: 如果你的事件是代码隐藏的,那么在XAML中:
<Grid SizeChanged="MainGrid_SizeChanged">
it will work. 它会工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.