1

Greatings、私は、Windows フォーム コントロールを持つ wpf ユーザー ライブラリ コントロールを作成しています。プロパティ クラス ライブラリ コントロール (Windows フォーム コントロール プロパティではない) に値を渡すことは可能ですか?、私はこれを持っています:

WPF ユーザー コントロール ライブラリ (XAML):

<wfi:WindowsFormsHost Height="300" Name="winFormsHost" VerticalAlignment="Top" >

   <wfr:ReportViewer x:Name="rptViewer" ProcessingMode="Remote"/>

</wfi:WindowsFormsHost>

....

WPF ユーザー コントロール ライブラリ (C#):

public partial class ReportViewer : UserControl
{

        public static readonly DependencyProperty UrlReportServerProperty =
            DependencyProperty.Register("UrlReportServer", typeof(string),    typeof(ReportViewer),
                                        new PropertyMetadata((string)""));
.... // Other Dependecies properties

     public string UrlReportServer
     {
        get { return (string)GetValue(UrlReportServerProperty);}
        set { SetValue(UrlReportServerProperty, value); }
     }
............ // Other properties

     public ReportViewer()
     {
            InitializeComponent();
            this.DataContext = this;

            ReportViewerLoad();
     }
     public void ReportViewerLoad()
     {
             rptViewer.ProcessingMode = ProcessingMode.Remote;

             rptViewer.ServerReport.ReportServerUrl =
                        new Uri(UrlReportServer);
...... //Pass credentials to server reports and parameters to Report with Properties.

             rptViewer.ServerReport.Refresh();
                this.rptViewer.RefreshReport();
     } 

参照ライブラリを使用した WPF アプリの MainPage (XAML):

<WPFControlsSol:ReportViewer HorizontalAlignment="Left" Margin="0,0,0,0" 
                             VerticalAlignment="Top" Width="644"
                             UrlReportServer="{Binding Url}"
</WPFControlsSol:ReportViewer>

WPF アプリ、メインページ (C#):

public partial class MainPageView : Window
{
        public MainPageView()
        {
            InitializeComponent();

            ViewModel viewModel = new ViewModel(); 
            DataContext = viewModel;

        }
}

ViewModel で:

public class ViewModel : ViewModelBase
{

        private string _url;  .... // Other attributes

        public string Url
        {
            get { return _url; }
            set 
            {
                if (_url != value)
                {
                    _url = value;
                    RaisePropertyChanged("Url"); //Notification Method own MVVM  Template I use.
                }
            }
        } .... // Other properties 



        public ViewModel()
        {

           LoadReport();
        }  



        public void LoadReport()
        {
            Url = "http://IPSERVER"; .... // Other properties 
        }

しかし、これは機能しません。

4

3 に答える 3

0

インターネットを検索すると、いくつかの解決策が見つかりました。以下のページをご覧ください。

チュートリアル: WPF アプリケーションでの ReportViewer の使用

WPF でレポート ビューアー コントロールを使用する

Windows Presentation Foundation (WPF) でレポート ビューア コントロールを使用する

WPF で MS ReportViewer を使用すると、適切なヒントが含まれます。

WindowsFormsHost.PropertyMap MSDN のプロパティ ページには、WPF コントロール プロパティを WinForms プロパティに、またはその逆に変換する方法が示されています。

WindowsFormsHost を介して WPF ユーザー コントロールから Windows フォーム ユーザー コントロールにパラメーターを渡す

WPF UserControls を WinForms に統合します (逆ですが、有効な方法が提供されます)。

更新 >>>

私はあなたの問題を本当に理解していません。私が提供したこれらのリンクのアドバイスに従わない場合は、コントロールを内部UserControlでホストする Windows フォームを作成し、ReportViewerその上で必要なすべてのプロパティを宣言してくださいUserControl。次に、次のように XAML を使用します。

<wfi:WindowsFormsHost Height="300" Name="winFormsHost" VerticalAlignment="Top" >
    <YourWinFormsUserControlWithInternalReportViewer UrlServer="Something" 
        Path="Some/Path/Report.rdl" User="Geert" Password="password" />
</wfi:WindowsFormsHost>
于 2013-10-10T16:08:45.190 に答える
0

EventHandler Delegateを使用して、イベントを発行およびサブスクライブします。情報の準備ができたら、イベントを発生させ、必要な情報をEventArgs

于 2013-10-10T15:37:32.403 に答える