点击此处---> 群内免费提供SAP练习系统(在群公告中)
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
这是ReportSourceBehaviour:
命名空间Wpf_Mvvm_CrystalReport.Reports { 公共静态类ReportSourceBehaviour { 公共静态只读System.Windows.DependencyProperty ReportSourceProperty = System.Windows.DependencyProperty.RegisterAttached( " ReportSource", typeof(对象), typeof(ReportSourceBehaviour), 新的System.Windows.PropertyMetadata(ReportSourceChanged)); 私有静态无效ReportSourceChanged(System.Windows.DependencyObject d,System.Windows.DependencyPropertyChangedEventArgs e) { var crviewer = d作为SAPBusinessObjects.WPF.Viewer.CrystalReportsViewer; 如果(crviewer!= null) { crviewer.ViewerCore.ReportSource = e.NewValue; } } 公共静态无效SetReportSource(System.Windows.DependencyObject目标,对象值) { target.SetValue(ReportSourceProperty,value); } 公共静态对象GetReportSource(System.Windows.DependencyObject target) { 返回target.GetValue(ReportSourceProperty); } } }
这是MainWindow.xaml:
<窗口 xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x =" http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d =" http://schemas.microsoft.com/expression/blend/2008" xmlns:mc =" http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local =" clr-namespace:Wpf_Mvvm_CrystalReport.Views" xmlns:Viewer =" clr-namespace:SAPBusinessObjects.WPF.Viewer; assembly = SAPBusinessObjects.WPF.Viewer" x:Class =" Wpf_Mvvm_CrystalReport.Views.MainWindow" mc:Ignorable =" d" xmlns:dd =" clr-namespace:Wpf_Mvvm_CrystalReport.ViewModels" d:DataContext =" {d:DesignInstance dd:MainWindowViewModel,IsDesignTimeCreatable = True}" xmlns:prism =" http://prismlibrary.com/" 棱镜:ViewModelLocator.AutoWireViewModel =" True" xmlns:rpt =" clr-namespace:Wpf_Mvvm_CrystalReport.Reports" Title =" MainWindow" Height =" 300" Width =" 300"> <网格>
这是MainWindowViewModel.cs:
使用CrystalDecisions.CrystalReports.Engine; 使用Prism.Mvvm; 使用Wpf_Mvvm_CrystalReport.Reports; 命名空间Wpf_Mvvm_CrystalReport.ViewModels { 类MainWindowViewModel:BindableBase { 公共ReportDocument报告{ 组; } 私人ushort _Flow = 2; 公共超短流 { 得到{return _Flow; } 设置{SetProperty(ref _Flow,value); } } 公共MainWindowViewModel() { 报告=新的CrystalReport1(); } } }
太好了,谢谢你的信息。
一周热门 更多>