Is it possible to pass current DataContext as ContructorParameter of ObjectDataProvider?

It would be very useful to pass DataContext as parameter for DataTemplate:
<DataTemplate>
<DataTemplate.Resources>
<ObjectDataProvider x:Key="ServiceDataProvider" ObjectType="{x:Type control:ServiceLayout}">
<ObjectDataProvider.ConstructorParameters>
/*here could be DataContext..but how?*/
</ObjectDataProvider.ConstructorParameters>
</ObjectDataProvider>
</DataTemplate.Resources>
<ContentPresenter
Content="{Binding
Source={StaticResource ServiceDataProvider}}" />
</DataTemplate>
I will use this DataTemplate in ListBox ItemTemplate. So, DataContext will be ListBoxItem bound object (type is known), and it is not very well to use ViewModel added as static resource as in https://social.msdn.microsoft.com/forums/vstudio/en-US/38a80213-9e72-44fc-8338-1a8bcfcf9c9f/objectdataprovider-binds-to-datacontext
May be there are any other ways to pass parameter to constructor from DataTemplate?

I am afraid that it is not possible to bind anything directly to the ConstructorParameters collections since it is just an IList property and not a dependency property.
What you could to is to use a BindingProxy class that extends the Freezable class and captures the DataContext as described here:
http://www.thomaslevesque.com/2011/03/21/wpf-how-to-bind-to-data-when-the-datacontext-is-not-inherited/
You can then bind the DataContext of the ListBoxItem to the Data property of a BindingProxy object and use a custom StaticResourceExtension class as described in the following TechNet article to pass the DataContext to the constructor:
http://social.technet.microsoft.com/wiki/contents/articles/23503.trick-to-use-staticresource-with-path.aspx
Here is a complete example:
public class ServiceLayout
public ServiceLayout(object dataContext) {
public class BindingProxy : Freezable
protected override Freezable CreateInstanceCore() {
return new BindingProxy();
public object Data {
get {
return (object)GetValue(DataProperty);
set {
SetValue(DataProperty, value);
public static readonly DependencyProperty DataProperty =
DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));
public class StaticResourcePath : StaticResourceExtension
public PropertyPath Path {
get;
set;
public override object ProvideValue(IServiceProvider serviceProvider) {
object o = base.ProvideValue(serviceProvider);
return (Path == null ? o : PathEvaluator.Evaluate(o, Path));
class PathEvaluator : DependencyObject
private static readonly DependencyProperty DummyProperty =
DependencyProperty.Register("Dummy", typeof(object),
typeof(PathEvaluator), new UIPropertyMetadata(null));
public static object Evaluate(object source, PropertyPath path) {
PathEvaluator d = new PathEvaluator();
BindingOperations.SetBinding(d, DummyProperty, new Binding(path.Path)
Source = source
var result = d.GetValue(DummyProperty);
BindingOperations.ClearBinding(d, DummyProperty);
return result;
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<DockPanel>
<DockPanel.Resources>
<local:BindingProxy x:Key="proxy" Data="{Binding}" />
<ObjectDataProvider x:Key="ServiceDataProvider" ObjectType="{x:Type control:ServiceLayout}">
<ObjectDataProvider.ConstructorParameters>
<local:StaticResourcePath ResourceKey="proxy" Path="Data"/>
</ObjectDataProvider.ConstructorParameters>
</ObjectDataProvider>
</DockPanel.Resources>
<ContentPresenter Content="{Binding Source={StaticResource ServiceDataProvider}}" />
</DockPanel>
</DataTemplate>
</ListBox.ItemTemplate>
Note that you have to move the resources to the root element of the DataTemplate, a DockPanel in the above example, for this to work, i.e. you cannot add the resources to <DataTemplate.Resources> but that should make no difference.
Hope that helps.
Please remember to mark helpful posts as answer to close your threads and then start a new one if you have a new question.

Similar Messages

  • 2.1 EA2: is it possible to pass current line number to external tool

    When I define external tools (in Tools / External Tools...) I can pass current file name and directory to my external program.
    Is it also possible to pass current line number (where is my cursor in open file) to external program as a parameter?
    If not then it would be a feature request from me :)
    And also - is it possible to develop SQL Developer extensions for syntax color coding of other file types (meaning other than PL/SQL files)?

    raymonds,
    For line numbers, we cannot do it at the moment as it is not exposed in that API, however, you can request it on http://sqldeveloper.oracle.com at the feature request station
    For color coding for another language, you can develop a hilighting plugin, but we do not have an easy way of associating the plugin with an editor for a specific file type. Again this would be a feature request.
    Remember, all these get evaluated each month and assigned into Enhancements for the tool. If enough folks vote for the feature, it is highly likely it will appear.
    Barry

  • Is possible to pass array/list as parameter in TopLink StoredProcedureCall?

    Hi, We need to pass an array/List/Vector of values (each value is a 10 character string) into TopLink's StoredProcedureCall. The maximum number of elements on the list is 3,000 (3,000 * 10 = 30,000 characters).
    This exposed two questions:
    1. Is it possible to pass a Vector as a parameter in TopLink's StoredProcedureCall, such as
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("STORED_PROCEDURE_NAME");
    call.addNamedArgument("PERSON_CODE");
    Vector strVect = new Vector(3000);
    strVect.add(“ab-gthhjko”);
    strVect.add(“cd-gthhjko”);
    strVect.add(“ef-gthhjko”);
    Vector parameters = new Vector();
    parameters.addElement(strVect);
    session.executeQuery(query,parameters);
    2. If the answer on previous question is yes:
    - How this parameter has to be defined in Oracle’s Stored Procedure?
    - What is the maximum number of elements/bytes that can be passed into the vector?
    The best way that we have found so far was to use single string as a parameter. The individual values would be delimited by comma, such as "ab-gthhjko,cd-gthhjko,ef-gthhjko..."
    However, in this case concern is the size that can be 3,000 * 11 = 33, 000 characters. The maximum size of VARCHAR2 is 4000, so we would need to break calls in chunks (max 9 chunks).
    Is there any other/more optimal way to do this?
    Thanks for your help!
    Zoran

    Hello,
    No, you cannot currently pass a vector of objects as a parameter to a stored procedure. JDBC will not take a vector as an argument unless you want it to serialize it (ie a blob) .
    The Oracle database though does have support for struct types and varray types. So you could define a stored procedure to take a VARRAY of strings/varchar, and use that stored procedure through TopLink. For instance:
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("STORED_PROCEDURE_NAME");
    call.addNamedArgument("PERSON_CODE");
    oracle.sql.ArrayDescriptor descriptor = new oracle.sql.ArrayDescriptor("ARRAYTYPE_NAME", dbconnection);
    oracle.sql.ARRAY dbarray = new oracle.sql.ARRAY(descriptor, dbconnection, dataArray);
    Vector parameters = new Vector();
    parameters.addElement(dbarray);
    session.executeQuery(query,parameters);This will work for any values as long as you are not going to pass in null as a value as the driver can determine the type from the object.
    dataArray is an Object array consisting of your String objects.
    For output or inoutput parameters you need to set the type and typename as well:
      sqlcall.addUnamedInOutputArgument("PERSON_CODE", "PERSON_CODE", Types.ARRAY, "ARRAYTYPE_NAME"); which will take a VARRAY and return a VARRAY type object.
    The next major release of TopLink will support taking in a vector of strings and performing the conversion to a VARRAY for you, as well as returning a vector instead of a VARRAY for out arguments.
    Check out thread
    Using VARRAYs as parameters to a Stored Procedure
    showing an example on how to get the conection to create the varray, as well as
    http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/varray/index.html on using Varrays in Oracle, though I'm sure the database docs might have more information.
    Best Regards,
    Chris

  • Is it possible to pass parameters through eventlisteners?

    Hello everyone!
    Inside a .fla file I have some buttons and each button will tween a different image to the stage. All the images are outside the stage in the same x and y position and I just need to tween the x coordinate.
    Now I'm working with an external document class where I'm trying to hold all my functions and I'm stucked with the Tweens. I'm willing to stay away from the flash tween engine and I'm trying to work with tweenLite.
    My question is: Is it possible to pass parameters through eventListeners so I can use something like this inside my docClass?
         public function animeThis (e:MouseEvent, mc:MovieClip, ep:int):void { //ep stands for endPoint.
         TweenLite.to(mc, 2, {x:ep});
    If this is possible, how am I supposed to write the listeners so it will pass the event to be listened for AND those parameters? And how to build the function so it will receive those parameters and the event?
    If this is not possible, what's the best approach to do this?
    Thanks again!

    So, I understand you need to match buttons with corresponding visuals.
    Here is a suggested approach.
    Since SimpleButton is not a dynamic class, I suggest you have an enhanced base class for these buttons that extends SimpleButton. What is enhanced is that button has reference to the target.
    I wrote code off the top of my head and it may be buggy. But concept is clear:
    This is base class for all the buttons:
    package 
         import flash.display.DisplayObject;
         import flash.display.SimpleButton;
         public class NavButton extends SimpleButton
              public var targetObject:DisplayObject
              public function NavButton()
    Now, this is your doc class that utilizes this new buttons:
    package 
         import flash.display.DisplayObject;
         import flash.display.MovieClip;
         import flash.display.Sprite;
         import flash.events.Event;
         import flash.events.MouseEvent;
         public class DocClass extends Sprite
              private var btnArray:Array;
              private var visuals:Array;
              // references to objects being swapped
              private var visualIn:MovieClip;
              private var visualOut:MovieClip;
              public function DocClass()
                   if (stage) init();
                   else addEventListener(Event.ADDED_TO_STAGE, init);
              private function init(e:Event = null):void
                   removeEventListener(Event.ADDED_TO_STAGE, init);
                   // buttons and MCs shouldn't be in the same array - otherwise it is counterintuitive
                   // assuming all the objects are on stage
                   btnArray = [price_btn, pack_btn, brand_btn, position_btn];
                   visuals = [g19_mc, g16_mc, g09_mc, g04_mc];
                   configObjects();
              private function configObjects():void
                   var currentVisual:MovieClip;
                   var currentButton:NavButton;
                   for (var i:int = 0; i < btnArray.length; i++)
                        currentVisual = visuals[i];
                        // hold original positioin
                        currentVisual.hiddenPosition = currentVisual.x;
                        currentButton = btnArray[i];
                        // set target MC
                        currentButton.targetObject = currentVisual;
                        currentVisual.addEventListener(MouseEvent.CLICK, placeObject);
                        currentButton.addEventListener(MouseEvent.CLICK, placeObject);
              private function placeObject(e:MouseEvent):void
                   // if NavButton is clicked - make new visual targeted for moving in and currently visible object subject for moving out
                   if (e.currentTarget is NavButton) {
                        visualOut = visualIn;
                        visualIn = NavButton(e.currentTarget).targetObject;
                   else {
                        // otherwise - move visual out
                        visualOut = visualIn;
                   swapVisuals();
               * Accompishes visuals swapping
              private function swapVisuals():void {
                   if (visualIn) TweenLite.to(visualIn, .3, { x:0 } );
                   if (visualOut) TweenLite.to(visualOut, .3, { x:visualOut.hiddenPosition } );

  • Is it possible to pass dynamic values to custom tag?

    Hi there, I'm trying to build a calendar custom tag so I can drop the calendar into an existing webpage easily.
    I have got the calendar displaying on the page but the problem I have is when I try to create 'previous' and 'next' links. Is it possible to pass parameters to a custom tag that have dynamic values?
    In PHP it would looks something like:
    <a href="bla.php?page=$pagenumber">next page</a>When I create the calendar object I set it to the current date so when I try to increase or decrease the month (next/prev month) it doesn't work because the code is run again and hence setting the current date again.
    Any ideas?
    Cheers in advance
    Message was edited by:
    MajorMahem

    for eg
    <a href=" Display.jsp?id='+<%=customerId%>">Result Page</a>
    Please try this,
    i didn't work out, any how apply this sample to your code

  • Is it possible to pass variables from Tidal to the Peoplesoft run controls?

    Does anyoen know
    •1) Is it possible to pass variables from Tidal to the Peoplesoft run control page such as current date?
    An example would be updating run control parameters for a PSQUERY.
    •a) From date
    •b) To date
    •c) Business units
    Thanks,
    Jay

    Edit the job - go to Run Controls Parameters tab - select the param you want in the Override column then click on the Variables button on the bottom and select the variable you want

  • Pass current sequence as argument in Customize Tool Menu

    Is it possible to pass the full path and filename as an argument under the Customize Tool Menu?
    Basically, I have an external tool that works on a sequence file and I'd like to call it from the Tools menu.  It's a Command type but I don't know what to put in the arguments.  I found a post where someone said use "%FILE%", but that did not work. 
    Also, if there are other keywords available, where is that list?
    Thanks. 
    Solved!
    Go to Solution.

    Hi Richard,
    It seems there isn't a way to do this using the Command type.  The problem is that you can't use an expression to specify the arguments for the executable and you need to use an expression to get the current sequence file's path.
    However,  you can wrap your executable in a sequence file that has only one step; calling your executable.  If you place a Call Executable Step in your sequence, you can specify the argument as the current file path by using the expression RunState.InitialSelection.SelectedFile.Path.
    Then add a new item to the Tools menu and select your wrapper sequence.
    Cheers, 

  • Is it possible to pass a string from an applet to the web site?

    Hi, everybody!
    Is it possible to pass a String from an applet to a web site (as a field value in a form, an ASP variable, or anything else). Basically, I have a pretty large String that is being edited by an applet. When a user clicks on the submit button, a different page will show up which has to display the modified string. The String is pretty large so it doesn't fit into the URL variable.
    Please, help!
    Thank you so much!

    Why do you want to do this in Java?
    Javascript is the correct language for these type of situations.
    for instance:
    in the head of your html document:
    <script language=javascript type="text/javascript">
    createWindow(form){
    if(form.text.value!=""){
    newDoc = new document
    newDoc.write(form.text.value)
    newWin = window.open(document,'newWin','width=200;height=150')
    </script>
    in the body:
    <form onSubmit="createWindow(this)">
    <p>
    Enter a String:<input type=text size=30 name="text">
    </p><p>
    <input type=submit value="submit"> 
    <input type=reset value="reset">
    </p>
    </form>

  • BSP: Use of dynpro services is not possible in the current system status

    Hello,
    in the component SRQM_INCIDENT_H i created a own button and eventhandler on the overview view.
    Here in this eventhandler i´m calling an own method from an own class. This method is doing a RFC in our ERP system.
    If i test the method this works fine.
    If i call this method in my eventhandler i get BSP error:
    Calling the BSP page was terminated due to an error.
    SAP Note
    The following error text was processed in the system:
    Use of dynpro services is not possible in the current system status
    Exception Class CX_SY_MESSAGE_IN_PLUGIN_MODE
    Error Name
    Program ZCL_CRM_CS_DATA_SERVICES======CP
    Include ZCL_CRM_CS_DATA_SERVICES======CM001
    ABAP Class ZCL_CRM_CS_DATA_SERVICES
    Method CREATE_CS_ORDER
    Line 54
    Long text -
    Error type: Exception
    Any ideas?
    thank you
    Best regards

    Hi,
           Web-UI cannot handle MESSAGE statements. if it's your own program, you should use the web-ui( view_manager->get_message_container or cl_crm_bol_core's global message container) alternatives to display the messages. If the message statement is being issued by a standard program, it's most usually deliberate attempt to fail on unrecoverable error. You can catch it by usin the try...catch CX_SY_MESSAGE_IN_PLUGIN_MODE ..where you call the standard functions.
    Regards,
    Arun Prakash

  • CRM70 Use of dynpro services is not possible in the current system status

    Hi all,
    i programmed in Webclient UI an own button which calls a Method of a zclass. Within this method i do a remote function call in ERP.
    I can test the method successfully but if i call it from CRM Webclient UI i have a BSP error:
    Business Server Page (BSP) error
    What happened?
    Calling the BSP page was terminated due to an error.
    SAP Note
    The following error text was processed in the system:
    Use of dynpro services is not possible in the current system status
    Exception Class CX_SY_MESSAGE_IN_PLUGIN_MODE
    Could one of you experts please give me a hind?
    Thank you
    Kind regards
    Manfred

    Solved,
    there was a SAP GUI "MESSAGE" in the ERP function call which is not possible for CRM Webclient UI.
    Kind regards
    Manfred

  • Use of dynpro services is not possible in the current system status

    Hi,
    I am new to all of this and new to SAP. I will bew self learing my way into CRM SOA,  working with the web service creaiton i keep getting the following errlr when rtying to Activate a new created web service:
    "Use of dynpro services is not possible in the current system status"
    not knowing the system that well i wonderin if there is missing configuration. This is CRM 7.0
    Exception Class CX_SY_SEND_DYNPRO_NO_RECEIVER
    Error Name DYNPRO_SEND_IN_BACKGROUND
    Program SAPLSKEY
    Include LSKEYU03
    Line 33

    Hi Keith,
    Welcome to the SCN forums!
    SAPLSKEY
    You should first check your Abap dumps using tranaction code ST22, this usually provides more detail on the problem.
    In this case I think it's trying to return a screen (or pop-up message) that can't be handled while activating the web service. The "SAPLSKEY" tells me that it might be licence related, do you have a valid developer's licence for Abap development work? If not apply for one (find out the procedure from other Abap developer's that you may work with) & check if that makes a difference while activating.
    Regards, Trevor

  • In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String

    In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String , for executing the Stored Procedure with Current date as the input .

    Hi Srinath,
    The below blog might be useful
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/06/executing-stored-procedure-from-sender-adapter-in-sap-pi-71
    PI/XI: Sender JDBC adapter for Oracle stored procedures in 5 days
    regards,
    Harish

  • Is it possible to pass some type of parameter/unique id FROM PDF?

    hi there,
    I will try to explain this as best as I can but please bear with me.
    I have Adobe Acrobat X Pro.
    We have drawings linked to each other in pdf.
    When you open a drawing (say, a layout of a house), my boss wants to be able to click on say, a door, and have all the information on that door pop up (size, manufacturer, when it was shipped, etc). The information log is stored in Excel. I know how to hyperlink to open an excel file FROM pdf, but cannot figure out how to open a specific sheet in Excel. So here is my question:
    1. How do I link to a specific sheet in Excel so it opens when I click on a link in the pdf file?
    Having said that, we are going to have around 1500 items and I don't want to have to create 1500 sheets (if that's even possible) to open the details for each one. So here is question #2:
    2.  Is it possible to pass some type of parameter to excel (or even Access) to know what item was clicked on the pdf file so I can write a macro/code in Excel to just fill in the details for that item? (Hence just needing one sheet instead of 1500?).
    Suggestions/path forwards are welcome.
    I hope this was clear and I thank you in advance.
    Thanks,
    Jessica

    There really isn't a way to do that. It would be possible to export an Excel sheet to a tab-delimited (or CSV, XML) file which could optionally be attached to the PDF. JavaScript inside the PDF could read the data file and extract the information for an item so it could be displayed somehow.

  • Is it possible to pass a field symbol as parameter from any method of view?

    Hi
    Is it possible to pass a field symbol as an importing parameter to teh globally declared attribute??

    While it is true that you can pass field symbols, they must be fully typed at the time you pass them  and they will be passed by value, not by reference. If you want to pass generically typed variables use a data reference (TYPE REF TO) instead.

  • Is it possible to pass the idoc between the same client

    Is it possible to transfer the idoc between the same system. I do not have two clients . I have only one client access. Is it possible to pass the idoc between the same client.

    Hello Preethy,
    This would not be possible as when you have to create the logical systems, you cannot create two entries for the same client.
    And  while defining the partner profiles as well.
    IDocs are basically for two systems or two clients.
    YOu may not require IDoc in one system itself.

Maybe you are looking for

  • Cross platform networking issue

    Okay, my group consists of about three dozen Macs (most on 10.3.9, but about half a dozen on 10.4.3) and we are hooked up to a Windows-based network which uses Extreme-Z IP to serve up the shared volumes to the Mac users. Recently, the corporate IT f

  • Received an error code -50 during manual backup?

    Please advise. I received this error while performing a manual backup to support my Time Machine back ups ... I was copying files to a Seagate GoFlex for Mac drive. This is a 1TB drive interfaced with FireWire 800 connection. On ocassion for no appar

  • Securing iPads in School Setting

    I've setup OS X Server and am controlling the iPads via Profile Manager. The only thing that is lacking is the ability to block the end user from deleting the Trust Profile and the Remote Management certificate. Am I missing something?  I have experi

  • Hi Are there any known compatibility issues with Lopic Pro 9 and Adobe PDF 9?

    Hi I am am Using a MacPro OS 10.5.8 2x2.66 GHz Dual-Core Intel Xeon and Logic 9.1.5. Also Adobe PDF 9.0 I can't print my score to pdf. The print box openes but The print button and the preview butten are not responsive! Is any body else experiencing

  • Can not open D3200 RAW

    I am unable to open any D3200 RAW files (format not recognised) I can open D3000 RAW files though I was using LR4.1 with Camera Raw 7.1 which is supposed to offer support for D3200 No lack I even installed LR4.2RC which included Camera Raw 7.2 again