WPF:水平拉伸日历?
有没有办法水平拉伸 WPF 日历控件?该控件允许我设置 HorizontalAlignment="Stretch",但这与将属性设置为“Center”具有相同的效果。它更改控件的宽度,但显示的日历在控件中心保持相同的大小。我想将显示的日历拉伸到控件的边缘。
我似乎记得它可以用 ViewPort 来完成,但我找不到任何显示如何做到这一点的内容。感谢您的帮助。
Is there a way to stretch a WPF Calendar control horizontally? The control will let me set HorizontalAlignment="Stretch", but that has the same effect as setting the property to "Center". It changes the width of the control, but the displayed calendar remains the same size in the center of the control. I'd like to stretch the displayed calendar to the edges of the control.
I seem to remember it could be done with a ViewPort, but I can't find anything that shows how to do it. Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想您可能正在寻找 Viewbox:
如果您将日历设为 Viewbox 的子级,它将应用 ScaleTransform 以使其占据所有可用空间。
I think you might be looking for Viewbox:
If you make the Calendar a child of a Viewbox, it will apply a ScaleTransform to make it take up all the available space.
我也遇到了同样的问题,但我在其他地方以不完整的方式找到了答案,所以我将其留在这里以供将来参考,毕竟这是7年前发布的!
就我而言,我想调整 DatePicker 控件显示的日历的大小。
为日历创建一个样式:
然后只需在 DatePicker 中调用它:
注意,我只指定 Viewbox 中的高度,那是因为(根据我读到的) ViewBox 均匀拉伸,因此它将采用两个尺寸中的最小尺寸。
I also faced the same issue but i found the answer elsewhere in an incomplete way, so i will leave it here for future reference, after all this was posted 7 years ago!
In my case i wanted to resize the calendar displayed by the DatePicker control.
Create a style for the calendar:
Then simply call it in the DatePicker:
Notice i only specificy the Height in the Viewbox, thats because (from what i read) the ViewBox stretches uniformly, so it will take the smallest of the two dimensions.