Get Control inside ContentControl as CommandParameter and programatically

Hi,
In a Window I've a ContentControl and a button 
<ContentControl x:Name="buscarRegion"
prism:RegionManager.RegionManager="{Binding RegionManager,
RelativeSource={RelativeSource AncestorType={x:Type Window}, Mode=FindAncestor}}"
prism:RegionManager.RegionName="{x:Static inf:RegionNames.BuscarRegion}"/>
<Button Content="Button" HorizontalAlignment="Left"
Command="{Binding ExcelGridCommand}" CommandParameter="???????"/>
Prism does the work and UserControl with a grid inside appears in ContentControl, my problem are two:
-How can i pass the grid as parameter to ExcelGridCommand?. Button is not inside the UserControl and in xaml i don't find the way to do it
-How can i access to grid programatically ? I've been trying with VisualTreeHelper:
ContentPresenter cpresenter = VisualTreeHelper.GetChild(this.buscarRegion, 0) as ContentPresenter;
var nChildCount = VisualTreeHelper.GetChildrenCount(cpresenter.Content as DependencyObject);
for (int x = 0; x<nChildCount; x++)
FrameworkElement child = VisualTreeHelper.GetChild(cpresenter.Content as DependencyObject, x) as FrameworkElement; //returns a Border :-(
if (child == null)
continue;
// Is child of desired type and name?
if ( child.Name.Equals("grid"))
// Bingo! We found a match.
MessageBox.Show("Found matching element [{0}]", "grid");
break;
} // if
No way, any idea ?
Thank's in advance

-How can i pass the grid as parameter to ExcelGridCommand?. Button is not inside the UserControl and in xaml i don't find the way to do it
foreach (Grid grid in FindVisualChildren<Grid>(buscarRegion))
if (grid.Name.Equals("grid"))
theButton.CommandParameter = grid;
<Button x:Name="theButton" Content="Button" HorizontalAlignment="Left"
Command="{Binding ExcelGridCommand}" />
You will have to get a reference to the Grid element programmatically and then set the CommandProperty of the Button in the code-behind of the view. Refer to the below code for details.
-How can i access to grid programatically ? I've been trying with VisualTreeHelper:
You could use the following helper method:
public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
if (depObj != null)
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
if (child != null && child is T)
yield return (T)child;
foreach (T childOfChild in FindVisualChildren<T>(child))
yield return childOfChild;
Usage:
foreach (Grid grid in FindVisualChildren<Grid>(buscarRegion))
if (grid.Name.Equals("grid"))
Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please only ask ONE question per thread.

Similar Messages

  • JS: Get Control that has the Focus and paste something into it

    Hi,
    I want to implement some clientside code that gets the control that has the focus and copy some text into it.
    Can this be easily accomplished?
    Thanks
    Sven

    Hi,
    According to your post, my understanding is that you want to get the focus element via JavaScript.
    We can use the document.activeElement to get the current active element.
    http://stackoverflow.com/questions/497094/how-do-i-find-out-which-dom-element-has-the-focus
    http://stackoverflow.com/questions/11277989/how-to-get-the-focused-element-with-jquery
    Then you can use the obtained focus element to paste text into it.
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]
    Jason Guo
    TechNet Community Support

  • Get the Type (U8, U16...I64) of controls inside a Cluster

    Hi,
    I have a cluster with several controls. 
    I would like to get the type of each control inside of it. To get the class is ok. This is simple and all of them are Digital. But I need to know if they are U8, U16, U32 ...... I64. 
    Any idea how to do this?
    Paul
    Solved!
    Go to Solution.

    I got it.
    I had to Convert the Element Refernce to Digital and then to use the property BitAccurateDataSize.
    I lost several hours to find the solution and in 5 minutes after I had posted my problem on forum I solved it . 

  • [svn:fx-trunk] 9180: When another popup is going away as the alert is going up, the Alert can get validated inside of addPopUp and its centering logic never got the event it expected .

    Revision: 9180
    Author:   [email protected]
    Date:     2009-08-07 15:11:43 -0700 (Fri, 07 Aug 2009)
    Log Message:
    When another popup is going away as the alert is going up, the Alert can get validated inside of addPopUp and its centering logic never got the event it expected.
    add the event listener earlier so it is ready if we get validated inside addPopUp
    QE Notes: versioning/baselines/mp_alert_mask_compatible.png needs updating.  I think the current baseline is incorrect.
    Doc Notes: None
    Bugs: SDK-22819
    Reviewer: darrell
    tests: checkintests mustella/components/alert
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-22819
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/Alert.as

    Hi or2tx2002, 
    We're really sorry to learn of all the equipment issues you've experienced in the last year. In order to discuss your replacement options, I ask that you please PM me with your wireless number, a contact number and a good time to reach you. I will be happy to reach out to you and bring resolution to this matter. 
    Thank you and I look forward to hearing from you soon. Make it a great day! 

  • How can I get Configurator off my work PowerMac and have my ipad, ipod4 controlled by my macbook pro from home?

    Hi, I put apple configurator on my work machine which has all my itunes, my entire Apple Macintosh History on it and used apple configurator thinking it would be a great way to sync all my devices. I get it now, that it doesn't do that for the private person but is really for an institution or employer. Be that as it may I threw away the app from my main computer and thought I would be done with it.
    I just reinstalled apple configurator and thought I took all devices off it. My ipad disappeared from the itunes menu. I plugged my ipad back into my machine and Paulz Config reappeared. I need to get this off my work PowerMac and have my ipad, ipod4 controlled by my macbook pro from home. And does it matter if I use the same email address that's listed with my power mac at work to easily switch the dominant mac over to my home from work. Things can get dicey at work and I don't want my life tied to the work power mac anymore. Thanks, Paul I realize there are a ton of questions in this. I am gratefull if I can just get the apple config off everything.

    To completely remove Apple Configurator from a Mac, you need to delete the application along with the following:
    ~/Library/Containers/com.apple.configurator.
    You may also want to delete the contents of ~/Library/Keychains and /var/db/lockdown to remove the Supervision Certificate, public and private keys and device pairing information. NOTE: There are other things in Keychains that you may or may not want to delete. Google "keychains" to learn more about what's in that folder.
    Good luck!
    ~Joe

  • Get control and indicator references in individual array

    Hi All,
    Aim : How to get control and indicators references in two different arrays ?
    What I tried :using Pane Reference i got controls but it does include indicator references.
    If sombody suggest on this, that would be great.
    Thank you.
    Solved!
    Go to Solution.

    What tst said (see attached VI)
    Attachments:
    Get Indicator references.vi ‏12 KB

  • HOWTO Get the text of "combo box" and "labe" controls with JavaAccessBridge

    HOWTO Get the text of "combo box" and "labe" controls with JavaAccessBridge.
    Please help,
    I'm trying to use the Java Access Bridge (JAB) 2.1 to get the text in Java Applet controls. I've been able to use the sample code in AccessInfo.cpp sample that comes with JAB to get text from "text" controls in a Java Applet. To clarify, I am referring to the "role" in the AccessibleContextInfo struct being set to "text" or "combo box" or "label".
    The problem is, when I use the AccessInfo.cpp sample to get text from a "combo box", the accessibleText data member comes back as FALSE, and thus any of the JAB text functions like GetAccessibleTextInfo fail to get any text information from "combo box" or "label" controls.
    I've also tried GetCurrentAccessibleValueFromContext on the "combo box" and "label" controls, but the text returned is empty.
    Can anyone help?

    I have new information in regards to this issue. A contact from Sun did get to me in email and relayed that that "label" objects store their text in the "name" data member of the AccessibleContext structure. This was a big help.
    But I'm still stuck trying to get information from "combo box" and other controls, like "push button". The contact said, the Java Access Bridge does not provide all the information because it is already implemented by other interfaces like AccessibleComponent, AccessibleAction, or AccessibleSelection. The contact did not allude to whether these opther interfaces can be used along side the Java Access Bridge or not. So, I'm left a step closer to the goal, but still stuck without the full solution.
    Can one take the Java Access Bridge functions, like say those used in the Ferret sample, and close the gap to get text back from "combo box", "push button", and other controls by using some other API in conjunction?

  • HT3140 put a date 1970 june 27 . and now the whole system is out of control i cant get to internet cannot change date and time  always when i opened system preferences stays in a waiting mode but doesnt show any opcion don t know what to do and i just bou

    put a date 1970 june 27 . and now the whole system is out of control i cant get to internet cannot change date and time  always when i opened system preferences stays in a waiting mode but doesnt show any opcion don t know what to do and i just bought this computer

    It may well be a driver issue but considering the loading: Xorg trying to load different drivers is somewhat normal. @cafe you can see that these are autoconfigured by X above the loading in the log:
    Jul 20 19:48:24 arch gdm-Xorg-:0[216]: (==) Matched intel as autoconfigured driver 0
    Jul 20 19:48:24 arch gdm-Xorg-:0[216]: (==) Matched intel as autoconfigured driver 1
    Jul 20 19:48:24 arch gdm-Xorg-:0[216]: (==) Matched modesetting as autoconfigured driver 2
    Jul 20 19:48:24 arch gdm-Xorg-:0[216]: (==) Matched fbdev as autoconfigured driver 3
    Jul 20 19:48:24 arch gdm-Xorg-:0[216]: (==) Matched vesa as autoconfigured driver 4
    As long as one of the drivers gets loaded, which it apparently does the failing of the others is fine.
    Was there an update maybe ?

  • Getting control of Apple id on apple mac and iphone 4s?

    HI, my old email address was my apple id and icloud and all my apps are linked to it.  Unfortunately I have forgotten my password and my ex business partner now owns the email account.  How do I get control of icloud and the other apps that are linked?

    http://www.apple.com/support/appleid/
    https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/
    https://discussions.apple.com/community/icloud/icloud.com
    http://www.apple.com/support/icloud/

  • How to get rid of "click to activate and use this control"

    Hi,
    Any idea how to get rid of "click to activate and use this control".
    I don't want user to click to start working with the form.
    We are using IE6, forms9i and 10g application server.
    Thanks in advance.
    Kumar

    I got the solution...
    Metalink - Note:357545.1
    Kumar

  • How and where can I get intel hd 4000 graphics drivers and controll panel to 3d settings ... I want to turn off my vertical sync! please someone has to help me with this problem!

    How and where can I get intel hd 4000 graphics drivers and controll panel to 3d settings ... I want to turn off my vertical sync! please someone has to help me with this problem!

    So are there any other ways to get there, or to change options there?
    And is it plausible to use 3d vision (like nvidia its one) but than without an nvidia graphics card. for watching movie's and gaming etc.
    Thank you!

  • I have iOS 7, but when I swipe up to control panel, the airport, airplay,and whatever the three icons shown below on the web picture are, do not come up, only the volume, brightness etc. how do I get them to show?

    I have iOS 7 , but when I swipe up to control panel the airport,airplay, and the icon that are supposed to be under them are not there. How do I make them come up?

    If you don't see the AirPlay icon in Control Center:
    1. Reset the AirPlay devices
    2. Reboot the router
    3. Reboot the iPad

  • Every time i try to download something, i get redirected to the home page and nothing happens (mac osx mavericks, 10.9.4) DETALS INSIDE!

    so basically I'm on a Macbook Pro and i have osx mavericks 10.9.4
    i tried to download HotSpot Shield. i go to their home page and click download and i get redirected to the home page and there is no download, NOTHING HAPPENS.
    same thing with trying to download magnet links and .torrent files on Piratebay.se. i click "Get this Torrent" and i get REDIRECTED TO THE HOME PAGE. the .torrent file doesn't appear in Downloads. NOTHING HAPPENS!!
    please help me. PLEASE!!

    Other browsers that you can look at:
    * http://caminobrowser.org/download/releases/
    * [http://en.wikipedia.org/wiki/ICab iCab]: http://www.icab.de/
    * http://www.seamonkey-project.org/releases/seamonkey1.1.19

  • How can I make a control inside a loop in a subVI change value when the calling VI's control changes?

    Hi.
    I think this is a pretty basic LV question, but I have not been able to find a good solution.
    I am attaching VIs that show the problem I am having, but obviously, the real application is a lot complicated, which forces me to try to do it this way.
    The issue is: I have a subVI with a Boolean control inside a loop.  When the control is true I want some action to take place.  When the subVI is run on its own, it works fine, acting properly when I set the boolean control to true via the LV FPGA interface from the host.  However, when I use it as a subVI, in which the top-level VI calls several instances of the subVI, I have the Boolean controls in the top level VI.  What is happening is that the false Boolean value with which the top-level VI starts is passed into the subVIs, and not updated, even though the control is inside the loop.
    Can any one suggest a good solution?
    Thanks,
    AlejandroZ
    Attachments:
    CallingVI.vi ‏7 KB
    subVI.vi ‏8 KB

    Hi.
    I know the example I posted might seem silly, but it was just to illustrate the problem I am having.  In reality this is the application:
    I have some LV FPGA code which uses a few FPGA IO to implement a serial link to communicate with a device.  Most of the time we are getting data from the device, so the serial link is used to send a read command, read in the data and put it into a FIFO.  However, I also wanted the VI to support sending data to the device, so I added an array control to put the data you want to send, and a boolean control to tell it you want to send it.
    Since sending and receiving data are done using the same FPGA IO, they cannot be independent operations, because they would garble each other. Therefore, in the subVI I have a loop in which I first read data if there is any to read, then check the boolean write control to see if there is data to write.
    As I mentioned, this works perfectly for talking to a single device.  However, we run into the issue of this topic when trying to replicate this for several devices.
    One easy solution is to not have the loop in the subVI, and have it in the calling VI (I am favoring this simple solution right now).  The only reason why I have not done this yet, is that the subVI has more than one loop, so I am going to have to create several subVIs.  I just posted to see if there was an even simpler solution...
    There have been some other possibly good solutions proposed here, though I am not sure if they work in LV FPGA.
    Thanks for all your responses.
    AlejandroZ

  • How to get controls of a vi to send signals more than once

    Hi,
    Recently I designed a rather neat VI that allows the user to quickly switch wiring and ID number characteristics on a certain device.  The inside of the VI is an orchestration of sequences and loops that allows user full control through one control loop that cycles through until the user selects a desired function, for which the loop terminates and performs the function.  After the function is complete, if the user has not pressed "stop", another loop brings the program back to the control loop.
    So the VI works great, but as someone who's been interested in automation, I want to try to take this to the next level.
    My next attempt was to put the finished VI as a sub-VI in a new VI that is meant to automate the user control process on the front panel.  I've attempted to use both a flat sequence and the state machine template to do this, and they work great for automatically pressing buttons when working with property nodes or local variable.  The problem, I've found, is that I don't know how to send signals to the Sub-VI from the connected controls at a constant rate without throwing it into a loop itself, which doesn't work because, of course, the sub-vi runs on it's own set of loops and there will be no iteration increment until the program inside the sub-vi terminates.
    Or, if the VI and it's inputs are left on it's own and I try to write values to the controls of the inputs, I can definitely change button positions, but, looking at the signal flows, no signal will be sent from the connected controls to the sub-vi.
    A second problem is that, due to my use of a program button that latches when pressed, I'm having a tough time trying to manipulate it will local variables or property nodes.  Because of the way it functions, the "value" property nodes shows up as purple and I'm not sure how to make it tap itself to operate how it did in the Sub-VI.
    Thanks in advance,
    Matt

    TeknoAXE wrote:
    ...The inside of the VI is an orchestration of sequences and loops that allows user full control through one control loop that cycles through until the user selects a desired function, for which the loop terminates and performs the function.  After the function is complete, if the user has not pressed "stop", another loop brings the program back to the control loop.
    Well, a tight polling loop is typically not a good design. have you tried the event structure instead?
    TeknoAXE wrote:
    The problem, I've found, is that I don't know how to send signals to the Sub-VI from the connected controls at a constant rate without throwing it into a loop itself, which doesn't work because, of course, the sub-vi runs on it's own set of loops and there will be no iteration increment until the program inside the sub-vi terminates.
    You can wire control references to the subVI and then poll the state of the controls on the toplevel VI via value properties.
    TeknoAXE wrote:
    Or, if the VI and it's inputs are left on it's own and I try to write values to the controls of the inputs, I can definitely change button positions, but, looking at the signal flows, no signal will be sent from the connected controls to the sub-vi.
    Of course you need to call the subVI from a parallel loop (for example) so other parts of the code don't get blocked.
    TeknoAXE wrote:
    A second problem is that, due to my use of a program button that latches when pressed, I'm having a tough time trying to manipulate it will local variables or property nodes.  Because of the way it functions, the "value" property nodes shows up as purple and I'm not sure how to make it tap itself to operate how it did in the Sub-VI.
    Latch booleans are not compatible with locals and value properties. A latch action boolean turns true until it is read by the code. If you were allowed to read (and reset it) it from multiple locations and via multiple mechanisms, you would get completely unpredictable code. You can always use switch action booleans and simulate latch action as needed using e.g. local variables.
    It is difficult to give more specific comments without seeing the code. What are the subVIs doing? Are they interactive too?
    If you don't mind attach your code and we will give more specific advice.
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for

  • Wi-fi on iPod touch is grayed out

    After restoring factory settings to my 3rd generation iPod touch, the wi-fi was grayed out along with iCloud, email, twitter, navigation, etc. I'm in the process of restoring it again and hopefully the newest update of 5.1.1 will fix the problem.

  • NS0 TAG IN XML

    Hi ALL, I have one problem, i want to remove NS1 from my target structure , because target webservice is not design in such way that it wonot take the ns1 as input. I used AF_Modules/XMLAnonymizerBean  module  in my receiver sopa adapter, now the pro

  • Video Streaming from Server

    My configuration at school: 20 iPads connected by Wifi to Server ( Mac Mini Server ML ) So i can upload and download iWork-Documents via WebDav. This document pool works fine My next idea is to set up a media pool. I download a lot of relevant videos

  • SESSION VARIABLES : HOW TO TEST FOR MULTIPLE USERS

    I have a username session variable set up on a localhost testing envirnoment. This works fine for one user, but when I open another occurence of the browser (or just another tab) to test for multiple users the system overwrites the session variable w

  • JAI TIFF - JPEG colour problem

    Hi all... I want to use JAI to convert from TIFF to JPEG. Here is my test program: import javax.media.jai.JAI; import javax.media.jai.RenderedOp; import java.awt.image.renderable.ParameterBlock; public class Test {      public static void main( Strin