Page 1 of 1

Problems when subclassing StiWpfViewerControl

Posted: Tue Oct 30, 2012 2:11 pm
by tpontow
Hello,

i need to create my own subclass of StiWpfViewerControl and use this in my window. But when the Viewer instance is initialized the following error occurs:

Code: Select all

The component "Wpf_Linq.MyViewerControl" does not have a resource identified by the URI "/Stimulsoft.Report.Wpf;component/viewer/stiwpfviewercontrol.xaml"
MyViewerControl is my own subclass of StiWpfViewerControl. As sample i attach a modified version of Stimulsoft Wpf sample project Wpf_Linq. In method

Code: Select all

Window1.btPreview_Click()
i changed the code to create my own viewer instance and add this to a StackPanel of a second window (instance of class Window2). The commented line of code which uses the original StiWpfViewerControl is working. To get the sample running you may have to replace the references to Stimulsoft-Dll with your own because i do not use the assemblies from GAC.

Can you help me get my sample working with the use of my own StiWpfViewerControl subclass?

Thanks
Thorsten Pontow
Wpf_Linq.zip
Sample project which is a modified Stimulsoft Wpf sample project (Wpf_Linq).
(52.77 KiB) Downloaded 241 times

Re: Problems when subclassing StiWpfViewerControl

Posted: Wed Oct 31, 2012 11:17 am
by Alex K.
Hello,

Unfortunately, but it is not possible. Can you please describe why do you need this additional subclass.

Thank you.

Re: Problems when subclassing StiWpfViewerControl

Posted: Wed Oct 31, 2012 1:25 pm
by tpontow
Hello Aleksey,

the main reason is that we want to write shared code in our projects. The users of our internal framework should use a factory class that creates for them a ViewerControl instance. The code should be the same in Forms, Silverlight and Wpf. So we need a subclass implemented in the three ways in the respective architecture (Forms, Wpf, Silverlight). Depending on the current architecture of the user project the factory delivers the right subclass which is also implementing a common interface. The user gets a control of that interface type. What ViewerControl it is excactly is transparent to the user.

It would be nice if Stimulsoft can offer a shared StiViewerControl in the future, so that shared code can be written without #if SILVERLIGHT directives.

By the way, we found a workaround. We are using ViewerControl as interal property. So a wrapper class implements our interface and all methods are using delegation to that internal ViewerControl. That works but a StiViewerControl / StiWpfViewerControl /StiSLViewerControl subclass would be nicer.

Maybe Stimulsoft will provide developers with a shared ViewerControl class in the future. I think that would be a cleaner way. A common interface StiIViewerControl containing all StiXXXViewerControl-methods (named equally in Forms, Wpf and Silverlight :-) ) would also be great.

Another question is why can method names of methods with same functionality not be the same? For example in Wpf it is

Code: Select all

StiWpfViewerControl.InvokeReportPrint() 
and in Silverlight it is

Code: Select all

StiSLViewerControl.InvokePrintReport()
and in Forms it is

Code: Select all

StiViewerControl.InvokePrint()
. That is not so funny for developers.

Thank you
Thorsten Pontow

Re: Problems when subclassing StiWpfViewerControl

Posted: Thu Nov 01, 2012 8:45 am
by Alex K.
Hello,

One interface for all ViewerControls does not possible make because it is different platforms. But all our viewers always inherited from one interface Stimulsoft.Report.Viewer.IStiViewerControl.
As a way, you can try to make a wrapper class under our and use it.

Thank you.