初始化网格行高不起作用
这是我的简单尝试应用程序,它创建一个包含 2 行的网格。第一行的高度绑定到一个属性。我分配给它的值仅在运行时有效。我试图让它在设计时也能工作,但我没能做到这一点(我使用了
请帮助我看看我错过了什么。谢谢你!
[编辑]
我这样做的原因是我想动态设置顶部网格行的高度,即。 Grid.Row="0"
,标题栏高度。在我的应用程序中的某个位置,视图已加载并与标题栏重叠。
this is my simple try-it application that create a grid with 2 rows. The 1st row's height is bound to a properties. The value I assigned to it only works at run-time. I tried to make it also work when design-time but I failed to do that (I used this thread to write my app).
Please help me to see what I miss. Thank you!
[Edit]
The reason why I do this is that I want to set dynamically the height of the top grid row, ie. Grid.Row="0"
, to be the title bar height. Somewhere in my app, the view loaded and overlap the title bar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你正在尝试做一个非常奇怪的把戏,这是不应该起作用的。尝试进行以下更改。
MainWindow.xaml.cs - 尽量保持代码隐藏清晰。
MainWindow.xaml
以及一个新的单独数据上下文类,其行为因模式而异:
You're trying to do a very strange trick, which is not supposed to work. Try to make the following changes.
MainWindow.xaml.cs -- try to always keep you code-behind clear.
MainWindow.xaml
And a new separate data context class, which behave different depending on the mode: