简体   繁体   English

如何在WPF中更改ReportViewer背景?

[英]How to change the ReportViewer Background in WPF?

i tried to change the ReportViewer Background from the original color Gray to White but i cant do that, please help me how to do that? 我试图将ReportViewer背景从原来的Gray更改为White但是我做不到,请帮助我该怎么做? this is my XAML code: 这是我的XAML代码:

...
<WinFormsHost>
    <rv:ReportViewer x:Name="Viewer" />
</WinFormsHost>
...

我希望灰色为白色

I'm not sure how to do this through XAML , but I instantiated my ReportViewer inside of my ViewModel . 我不确定如何通过XAML做到这一点,但是我在ViewModel内实例化了ReportViewer

WindowsFormsHost wfh = new WindowsFormsHost();
Reporting.WinForms.ReportViewer rv = new Microsoft.Reporting.WinForms.ReportViewer();
wfh.Child = rv;

I then set my parameters, ProcessingMode , path, etc... for the ReportViewer in the ViewModel including setting 然后,我在ViewModelReportViewer设置参数, ProcessingMode ,path等,包括设置

rv.BackColor = System.Drawing.ColorTanslator.FromHtml("#151515")

This successfully changed the background color in the ReportViewer You may need to call RefreshReport() before you see any effect. 这成功更改了ReportViewer的背景颜色。您可能需要调用RefreshReport()才能看到任何效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM