在 WPF 中自动调整 ReportViewer 的大小?
我正在 WPF 中设计 RDLC 报告。当然,我使用 WindowsFormsHost 来托管 ReportViewer 对象来显示报表。但是,由于每次计算和呈现报表时,报表的长度(具体而言,报表的高度)都会根据报表的实际内容而变化,因此我希望控件可以调整 ReportViewer 对象的大小。我怎样才能做到这一点?目前我将 WindowsForsHost 对象的高度设置为 Auto。但这仅在第一次加载WPF页面时生效,实际上没有显示任何报表(我们需要用户输入报表的一些参数,然后单击计算报表)。并且每当显示新报表时,对象的大小就不再改变。 谢谢!
I am designing a RDLC report in WPF. Naturally I am using WindowsFormsHost to host a ReportViewer object to display the report. However, since the length of the report, specifically, the height, of the report varies each time the report is calculated and rendered depending on the actual content of the report, I want the control can adjust the size of the ReportViewer object. How can I do that? Currently I set the height of WindowsForsHost object as Auto. But that only takes effect at the first time when the WPF page is loaded, when no report is actually displayed(We need the user to input some parameters for the report and then click to calculate the report). And whenever the new report is displayed, the size of the object is not changed any more.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我是否正确解决了您的问题。也许这会有所帮助:
您可以将一个控件的宽度和高度绑定到另一个控件的宽度和高度。
例如,通过定义具有正确宽度的第一个父元素的类型,这里是网格:
或通过元素的名称:
ActualWidth
是元素的当前宽度,如果 MyElement 的宽度改变时,绑定元素的宽度也会改变。Height
属性也是如此。I'm not sure I got your Problem right. Maybe this helps:
You can bind the
Width
andHeight
of a control to the width and height of an other control.For Example by defining the type of the first parent element that has the right width, here a grid:
or by the name of the element:
ActualWidth
is the current width of the element, if the width of MyElement changes, the width of the bound element changes too. Same for theHeight
property.