WPF: How to know the selection is come from datagrid or from ListBox?

Our application has a page which includes DataGrid and ListBox.
Both ItemSource are binding to PlateCells.
public ObservableCollection<CellVM> PlateCells
public class CellVM : BaseViewModel
public CellVM(int wellNumber)
WellNumber = wellNumber;
Row = wellNumber / define.NumberofWellsInRow;
Col = wellNumber % define.NumberofWellsInRow;
// row and col are 0-based
public int WellNumber { get; set; }
public int Row { get; set; }
public int Col { get; set; }
bool _isSelected;
public bool IsSelected
get { return _isSelected; }
set
_isSelected = value;
OnPropertyChanged("IsSelected");
string _sampleId;
public string SampleId
{ get { return _sampleId; }
set
_sampleId = value;
OnPropertyChanged("SampleId");
when a cell is selected, the cell will be highlight in both DataGrid and ListBox.
We also implement SelectAll button for both DataGrid and ListBox.
And SelectAll is ToggleButton. First time click is select All cells and second time click, it will unselect All cells.
What we notice when SelectAll button is click, all cells in both DataGrid and List box  are highlight.
After that click on a grid any cell, all cells becomes unselected in both DataGrid and ListBox.
 We assume this the behavior from DataGrid, after click SelectAll and click any cell in DataGrid will remove all selection and only highlight one cell in the datagrid.
However, this is behavior does not happen in ListBox. click any cell in ListBox only unselect that cell and not unselect all cells.
So we need to know click(selection) is coming from DataGrid or ListBox and take different actions.
How do we know the click is coming from DataGrid or ListBox? Thx!
JaneC

>>How do we know the click is coming from DataGrid or ListBox? Thx!
It depends on where in the code you want to be able to determine this. In the view model class you cannot really know if the user clicked in the ListBox or in the DataGrid because the view model knows nothing (and shouldn't know either) about any of these
controls. It only exposes a property that may be set from anywhere.
Handling the GotFocus event for any or each of the controls seems to be a good solution because then you can take the appropriate action depending on which control was focused/clicked.
You could of course move the code that is being executed when the GotFocus event occurs, i.e. the code in your event handler, from the code-behind of the view to the view model class by using a command in the view model class and then hook up the GotFocus
event to this command using event triggers:
<DataGrid>
<i:Interaction.Triggers>
<i:EventTrigger EventName="GotFocus" >
<i:InvokeCommandAction Command="{Binding YourCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</DataGrid>
How to do this is a topic of its own though. Please refer to my blog post about how to handle events in MVVM for more information:
http://blog.magnusmontin.net/2013/06/30/handling-events-in-an-mvvm-wpf-application/. You will need to reference an assembly that is part of the Expression Blend SDK which you can download from here:
http://www.microsoft.com/en-us/download/details.aspx?id=10801.
Anyway, as mentioned, handling the GotFocus event seems like a good idea here since you cannot determine which control that was clicked in the setter of the source property in the view model class.
Hope that helps.
Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.

Similar Messages

  • How to know the select statement perfomence

    how to know the select statement perfomence. suppose i have 10 select statements in my program. how will i know which select statement not performance wise poor.

    Go to ST04/
    Click on Detail Analysis menu button.
    Click on the SQL Request button.
    In the pup up give <table name> and execute.
    Then you will get a list of all the programs that have a select on that table.
    Or ST05 transaction t start the trace and run your program .Deactivate the trace in st05 .
    and display the trace.
    Regards,
    Ravi

  • How can I know the request is come from the link in header in the filter?

    I am using the tile for layout management and each page has a header, menu, and content body. I want to do something at the filter If the request is come from the commandlinks in the header and menu.
    How can I know the request is come from the link in header in the filter?

    Basically all you have to go on is the request data. Examine the encode/decode requirements for commandLink; you may be able to determine from the request attributes which commandLink has been invoked.

  • How to know the all user name from system/system login

    hi all,
    i want to know the all user names from system login who are the existing user like
    regards
    srinivas

    Hello,
    Using DBA_USERS will give more details
    select * from dba_users;Regards

  • How we know the selected node in a Tree object in a form?

    In a TREE object in forms, how can we know the current selected node by clicking a push button.
    lets say , there are 10 nodes in my tree, and 5th one i selected. But i want to store the selected node in a variable, when i click a button.
    please help
    thanks

    Hello
    I've just notice what might be a bug in Oracle forms because when I have the when-tree-node-selected trigger present for the tree (It does not matter if it executes null or some code), the code in option 1 works fine on a when-button-pressed trigger on a button item. This is what I had done to give you a reply.
    My second option will work because you're populating a parameter with when-tree-node-selected trigger which is then readable form anywhere else in the form. All you add is a check on when-button-pressed. Also for bug handling you need to consider setting the value to null when deselecting. I have this option working currently in one of my applications.
    DECLARE
         num_selected NUMBER;
         htree ITEM;
    curren_node FTREE.NODE;
    BEGIN
    htree := find_item('tree.form_list');
    num_selected := ftree.get_tree_property(htree,ftree.selection_count);
    for j in 1..num_selected
    LOOP
    curren_node := ftree.get_tree_selection(htree,j);
    message('hello :'||ftree.Get_Tree_Node_Property(htree,curren_node,ftree.node_value),acknowledge);
    end loop;
    END;     
    cheers
    Q

  • How to know the select stmt used in creating a table?

    Hi,
    If we create a table by selecting some records form another table, can we see the select statement used to create that table.
    example: Create table emp2 as select * from emp where deptno=20;
    is there any data dictionary table which stores select * from emp where deptno=20
    Thanks in advance.
    Edited by: 805791 on Jul 28, 2012 9:01 PM

    No. The SELECT statement is not associated with the table in the data dictionary.
    If the statement was executed recently, you may find the entire CREATE TABLE in the V$SQL view. Or, if you have licensed the AWR, you may find it in the DBA_HIST_SQLTEXT view. But there is no guarantee that the query will be in either view.
    Justin
    Edited by: Justin Cave on Jul 29, 2012 3:46 AM
    Additionally, this question doesn't appear to relate to the Oracle Call Interface so it should probably have been asked in a different forum. The General Questions forum or the SQL and PL/SQL forum would have been more appropriate.

  • How to grab the view that comes from Onyx?

    Hello,
      i started using Onyx project recently. That's really amazing what it does. I am wondering if there is some possibility to check the main view ... let my try to explain this.
    I want to change option for esxi5 box - advanced/Logging to external syslog server.
    While in gui i did my steps and Onyx prints the output:
    # ------- UpdateOptions -------
    $changedValue = New-Object VMware.Vim.OptionValue[] (1)
    $changedValue[0] = New-Object VMware.Vim.OptionValue
    $changedValue[0].key = "Syslog.global.logHost"
    $changedValue[0].value = "tcp://x.x.x.x:514"
    $_this = Get-View -Id 'OptionManager-EsxHostAdvSettings-456'
    $_this.UpdateOptions($changedValue)
    This is working as expected. I can throw this to powercli and it will set up the option. This will work only for that particular esxi box. I want to create a loop that will change this option for each esxi box in the cluster.
    The view that onyx is using is : "Get-View -Id 'OptionManager-EsxHostAdvSettings-456'"
    So he already knows the view/host moref .
    But if i would like to have this in a loop so it will do it for each host, so  how can i get to that kind of view ?
    So far i could only build something like
    foreach($vmhostview in (get-view -viewtype HostSystem -Searchroot (get-cluster "xxyyzz").id))
    $changedValue = New-Object VMware.Vim.OptionValue[] (1)
    $changedValue[0] = New-Object VMware.Vim.OptionValue
    $changedValue[0].key = "Syslog.global.logHost"
    $changedValue[0].value = "tcp://x.x.x.x:514"
    $number=$vmhostview.moref.split("-")[1]
    $_this = Get-View -Id OptionManager-EsxHostAdvSettings-$number
    $_this.UpdateOptions($changedValue)
    Which is totally stupid approach i belive although it's working.. splitting moref...
    After some time i noticed that
    http://pubs.vmware.com/vi-sdk/visdk250/ReferenceGuide/vim.option.OptionManager.html
    Says that OptionManager is the property from Config manager. So from that i could get the id of this view:
    ((get-vmhost myHost |get-view).ConfigManager.AdvancedOption).ToString()
    which will result in output : OptionManager-EsxHostAdvSettings-456
    So having this i could do my loop at the end:
    foreach($vmhostview in (get-view -viewtype HostSystem -Searchroot (get-cluster "xxyyzz").id))
    $changedValue = New-Object VMware.Vim.OptionValue[] (1)
    $changedValue[0] = New-Object VMware.Vim.OptionValue
    $changedValue[0].key = "Syslog.global.logHost"
    $changedValue[0].value = "tcp://x.x.x.x:514"
    $_this = Get-View -Id ($vmhostview.ConfigManager.AdvancedOption).ToString()
    $_this.UpdateOptions($changedValue)
    Now i do not know that it was just a luck that i found the location of this view name or is this the way how i am supposed to find the view id name. I am wondering how other people are handling that kind of case, if there is easier way to do it. If someone could share his experience i would really appreciate it.
    Regards,
    Greg

    There is no need to construct these View-Ids as you see them coming from Onyx.
    In fact I would write that script like this
    $changedValue = New-Object VMware.Vim.OptionValue[] (1)
    $changedValue[0] = New-Object VMware.Vim.OptionValue
    $changedValue[0].key = "Syslog.global.logHost"
    $changedValue[0].value = "tcp://x.x.x.x:514"
    Get-View -ViewType HostSystem -Searchroot (Get-Cluster "xxyyzz").ExtensionData.MoRef | %{
      $optMgr = Get-View $_.ConfigManager.AdvancedOption
      $optMgr.UpdateOptions($changedValue)
    Move the part that doesn't change with each HostSystem outside the loop
    The ConfigManager is an array with MoRefs that point to the respective Managers. You can just do a Get-View with a MoRef and it will return the object representing the Manager
    From the Manager object you can now call the method
    Btw, you better consult the latest SDK Reference.
    You can find the HostConfigManager here.

  • How to know the spool requests generated from my program?

    hi
         I want to get the spool request(s) that are generated from my report that's run either in foreground or background? how to know this? i know that we can go to sm37 and see, but is there any table or fm which stores this data? if i give my program name that's run on a particular date, i should get the spool request numbers. tsp01 only has the spool no. and not the program name..pl suggest...thanks all
    Sathish. R

    Hi ,
    The system field sy-spono contains the spool numbers .
    If you have such requirement, you can create one custom table with fields :
    spool no, program , date , time
    whenever you run ur program update this table ,
    with system fields . spono , sy-repid , sy-datum and sy-uzeit .
    Thaks .

  • How to track the URL that comes from a referred page using XSQL Custom Handler

    Hi,
    I have a cold fusion page(say cf.cfm) that sent a request to xsql page(say test.xsql) and then xsql page displays results. I want to capure the URL of cf.cfm page and then after checking its host name and path name for correctness then want to display the test.xsql results.
    Please let me know how can I capture URL of the refered page(cf.cfm) in the Custom Handler and then I want to extract host-name and path-name out of that url and on the basis of their values I want to display the result of XSQL page(test.xsql).
    Regards
    a2012

    req.getHeader("Referer") will return the referring url

  • How to know the record status changing from NEW to INSERT while keying-in a field

    Thanks to Kevin Clarke & Steven Declercq for helping me out with my previous queries.
    Can any one out there tell me how to intercept when the reocrd status is changing from NEW to INSERT (while a field is being keyed-in in a blank(new) record).
    Thanks
    Brijesh

    Hi Kevin,
    Thanks.
    Unfortunately, I could'nt find a trigger named 'ON-DATABASE-RECORD'.
    Are you sure it exists?
    Cheers
    Brijesh

  • How to get the selected values from the shuttle

    Hi
    Please tell me how to get the selected option values from the shuttle leading list.
    Thanks

    you can also obtain the option values present in the leading and trailing lists using the
    following methods:
    public String[] getLeadingListOptionValues(OAPageContext pageContext, OAWebBean
    webBean)
    public String[] getTrailingListOptionValues(OAPageContext pageContext, OAWebBean
    webBean)For example, the following code sample returns an array of values in the trailing list, ordered according to the
    order in which they appear in the list:
    String[] trailingItems =
    shuttle.getTrailingListOptionValues(pageContext, shuttle);Thanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Displaying the selected multiple records from node using onleadselect event

    Hi all,
    How to display the selected multiple records from node to node using onleadselect event.
    i came to know tht to fulfill this requirement i need to use the method get_selected_elements,
    how to use this method in my event??
    sree

    Hi Sree,
    Try below code..
    DATA : lo_nd_it_lips TYPE REF TO if_wd_context_node,             // This is first node
                 lo_el_it_lips TYPE REF TO if_wd_context_element,
                 ls_it_lips TYPE wd_this->Element_it_lips,
                 lt_it_lips TYPE wd_this->Elements_it_lips.
               DATA: wa_temp TYPE REF TO if_wd_context_element,
                lt_temp TYPE wdr_context_element_set.
    * navigate from <CONTEXT> to <IT_LIPS> via lead selection
          lo_nd_it_lips = wd_context->path_get_node( path = `ZRETURN_DEL_CHANGE.CHANGING_3.IT_LIPS` ).
          CALL METHOD lo_nd_it_lips->get_selected_elements
            EXPORTING
                INCLUDING_LEAD_SELECTION = ABAP_true
            RECEIVING
              set = lt_temp.
          DATA lo_nd_pack_mat TYPE REF TO if_wd_context_node.          //Second Node
          DATA lo_el_pack_mat TYPE REF TO if_wd_context_element.
          DATA ls_pack_mat TYPE wd_this->Element_pack_mat.
          DATA lt_pack_mat TYPE wd_this->Elements_pack_mat.
    * navigate from <CONTEXT> to <PACK_MAT> via lead selection
          lo_nd_pack_mat = wd_context->get_child_node( name = wd_this->wdctx_pack_mat ).
          lo_nd_pack_mat->get_static_attributes_table( importing table = lt_pack_mat ).
          LOOP AT lt_temp INTO wa_temp.
            CALL METHOD wa_temp->get_static_attributes
              IMPORTING
                static_attributes = ls_it_lips.
                  ls_pack_mat-vbeln = ls_it_lips-vbeln.
                  ls_pack_mat-material = ls_it_lips-matnr.
                  ls_pack_mat-vgbel = ls_it_lips-vgbel.
                    append ls_it_lips to lt_unpack.
                  CLEAR ls_pack_mat.
           ENDLOOP.
    Cheers,
    Kris.

  • Does anyone know how to invert the selection of thumbnails in Reader / Acrobat?

    Please help me,
    Does anyone know how to invert the selection of thumbnails in Reader / Acrobat?

    Hello,
    Could you please suggest the Acrobat/ Reader version at your end? Please check if this article helps - Adobe Acrobat X Standard * Rearranging pages in a PDF
    It's for Acrobat standard but the steps are same
    ~Deepak

  • How to know the the list of tables with no rows inside a schema?

    with reference to
    http://www.ss64.com/orad/USER_TABLES.html
    How to know the the list of tables with no rows inside a schema?
    I try this select table_name from user_tables where num_rows=0;
    I can found one table that is empty.
    So what's the query to return list of tables in a schema which has no rows?
    thanks

    You can do that only if your have collected the stats properly. Otherwise its going to show you wrong information.
    Check this out...
    SQL> drop table t
      2  /
    Table dropped.
    SQL> create table t
      2  as
      3  select level no from dual connect by level <=100
      4  /
    Table created.
    SQL> select table_name,num_rows from user_tables where table_name = 'T'
      2  /
    TABLE_NAME                       NUM_ROWS
    T
    SQL> begin
      2      dbms_stats.gather_table_stats(user,'T');
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> select table_name,num_rows from user_tables where table_name = 'T'
      2  /
    TABLE_NAME                       NUM_ROWS
    T                                     100
    SQL>Thanks,
    Karthick.

  • How to know the progress of the Sync when I call PullAsync()

    Hi,
    I am developing a Windows 8.1 app, In that I am using offline data concept using Azure mobile services with JavaScript Backend.
    My questions is how can I show the status or progress of the Sync When I call PullAsync() method.... I want to show the number of records sync or how much percentage synced like that...
    private async void ButtonPull_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
    await todoTable.PullAsync();
    //How to know the progress of sync
    await RefreshTodoItems();

    Hi Narendra,
    I suggest you to check this information for more details.
    PullAsync() call can either pull all items from the remote table, or just pull a subset of the items. Only pulling some items from the table is often advisable, as stuffing everything from the (potentially large) remote database table into the (restricted by
    the device memory) local table may have some bad performance implications. You can pass an OData-formatted query to select which items to pull from the server, or you can also use the (more friendly) Linq expressions to determine the query of items to be pulled.
    var localTable = client.GetSyncTable<TodoItem>();
    var query = localTable.Where(t => !t.Complete);
    await localTable.PullAsync(query);
    var localItems =
    await localTable
        .Select(i => i.Text)
        .ToListAsync();
    AddToDebug("Items from the server (in the local table): {0}",
    string.Join(", ",
    localItems));
    One important thing to notice regarding pull operations – if there are items in the pending synchronization queue, those items are first pushed over to the server, then the pull operation takes place. That prevents a scenario where an update is done to a
    local item, but a pull operation would overwrite the changes locally and potentially leave the data in an inconsistent state. That’s one the first synchronization rule: a pull triggers a push. In the example below, the insert operation for the “Buy milk” item
    will first be pushed to the server, then the items will be pulled into the local table.
    await client.SyncContext.InitializeAsync(store);
    AddToDebug("Initialized the sync context");
    var localTable = client.GetSyncTable<TodoItem>();
    var item =
    newTodoItem { Text =
    "Buy milk", Complete =
    false };
    await localTable.InsertAsync(item);
    var query = localTable.Where(t => !t.Complete);
    await localTable.PullAsync(query);
    var localItems =
    await localTable
        .Select(i => i.Text)
        .ToListAsync();
    AddToDebug("Items from the server (in the local table): {0}",
    string.Join(", ",
    localItems));
    for us to better understand both Push() and pullasync() feature is used while querying from the Database.
    http://blogs.msdn.com/b/azuremobile/archive/2014/04/07/deep-dive-on-the-offline-support-in-the-managed-client-sdk.aspx
    Girish Prajwal

Maybe you are looking for

  • Help popup on click of a button

    Hi All, The requirement is on click of a URL link on the adobe form, a popup should come which will have help text regarding certain field. Currently this is done by creating webdynpro application which will have the help text. On click of URL, the p

  • Error converting to cap file

    Hello everyone, I tried to follow sample of java card kit, but I've got this error when I 'd like to convert class file to cap file with converter. Assertion (precondition) [member != null] failed at: What's wrong ???? It's out only jca and exp file

  • My iPhone 4s is no longer working.

    My iPhone 4s is no longer working. It kept turning off and on on it's own and i tried to restore it. I pressed the lock and home button. I connected it to itunes as it says. Once in itunes it says the iPhone is on recovery mode and then when it is su

  • Failure id 90DX6C-56S​5S1-9XL03f​-60S403 - A disk read error occurred. Press Ctrl+Alt+D​el to restart.

    Model: HP G62 Notebook PC System ID: 1439 Product ID: WR444EA¤UUW Warranty Start Date: 08/06/2010 Processor Type: Intel(R) Pentium(R) CPU    P6000 @ 1.87 GHz Processor Speed: 1870 MHZ Memory Size: 4096 MB RAM BIOS Date: 06/28/2010 BIOS Revision: F.0B

  • Can any one tell me how to remove the 3 buttons at the top of a dialog?

    Hi all Can any one tell me how to remove the 3 buttons at the top of a dialog? The Close, Minimize and the other I don�t know what you call that one. Thanks for you time All Have a great day Craig