Home Forums WPF controls Xceed DataGrid for WPF No change notification for SelectedItems Dependency Property

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #27133 |

    I posted this in another thread (http://xceed.com/CS/forums/thread/7462.aspx), but haven’t received a response.  Therefore, I’ll repost it here.

    I’m trying to get notification when the SelectedItems property has changed.  I’d prefer a SelectionChanged event, as Microsoft provides on their WPF ListView and on their Silverlight DataGrid.  However, it doesn’t exist in the Xceed DataGrid.

     In this thread(http://xceed.com/CS/forums/thread/7462.aspx), it says I should register for change notifications for the SelectedItem Dependency property.  This works great for single selection, but not for multi-select datagrids.

     I have a DataGrid with SelectionMode set to SelectionMode.Extended.  I have registered a change notification for the SelectedItems dependency property. When selecting multiple items using the Ctrl-Shift key, no change notification event is fired, even though the SelectedItems.Count property has increased.

     Can anyone suggest a better way to do this?  Is there something wrong with the code I’m using?

     Here is my code:

    ———————————————————————————————

    DependencyPropertyDescriptor SelectedItemsChangedDescriptor =
    DependencyPropertyDescriptor.FromProperty(DataGridControl.SelectedItemsProperty,
    typeof(DataGridControl));

    SelectedItemsChangedDescriptor.AddValueChanged(myGrid,
    new EventHandler(OnSelectedItemsChanged));

    private void OnSelectedItemsChanged(object sender, EventArgs e)
    {
    // Do something with this event
    }  

    ——————————————————————————————————

    Imported from legacy forums. Posted by Todd (had 3498 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Todd,

       We did see your first post, but couldn’t respond at the moment. Thank you for your patience.

       We noted your suggestion regarding the selection changed event. At the moment, you can receive notification regarding the selected items by using this little trick:

       INotifyCollectionChanged selectedItems = grid1.SelectedItems as INotifyCollectionChanged;

       selectedItems.CollectionChanged += myHandler;

     
     

    Imported from legacy forums. Posted by Marcus [Xceed] (had 1661 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks!  I’ll give this a try.

    Imported from legacy forums. Posted by Todd (had 720 views)

    User (Old forums)
    Member
    Post count: 23064

    That worked great!  Thanks again.

    Imported from legacy forums. Posted by Todd (had 694 views)

    User (Old forums)
    Member
    Post count: 23064

    Is there a response to this issue yet?

     It seems that although the dependency property exists, it is not thrown at present.

    Imported from legacy forums. Posted by Jeffrey (had 3446 views)

    User (Old forums)
    Member
    Post count: 23064

    I am having problem with this change notification as well. It was working before but now the notification is not fired.

    Is this a bug?

    Imported from legacy forums. Posted by Serene (had 419 views)

    Xceed Support
    Member
    Post count: 5658

    Please refer to the following KB article: http://xceed.com/KB/questions.php?questionid=224

    Imported from legacy forums. Posted by Jenny [Xceed] (had 3236 views)

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.