Hi,
I am working on XAM combo editor and I have bind location with Combo editor. But we want that we can select multiple location at one time. and selected all location how we can get in ViewModel. Because Right now we have set Allow Multiple Selection property so, we are able to select multiple data items, but we are not able to get all selected data in View Model. I have set Multiple selected Items property but as i add then multiple selection does not work.
<ig:XamComboEditor IsEditable="True" Name="LocationComboBox" Grid.Row="1" Grid.Column="2" EmptyText="Select ..." ItemsSource="{Binding Path=Locationdata}" SelectedValuePath="Location_Id" DisplayMemberPath="Location_Name" SelectedItem="{Binding SelectedLocation}" AllowMultipleSelection="True" IsSelectedMemberPath="Location_Name" />
Please any help would be a appreciate.
Hello Pri,
Thank you for your post.
I have been looking into it and the code snippet that you have provided. In order to be able to bind the selected items to a collection from your ViewModel you need to define ObservableCollection of objects and bind the ‘SelectedItems’ property to it.I created short sample application based on your scenario to show you how you can implement the functionality that you are looking for. I created ObservableCollection from object and bind to the SelectedItems property of XamComboEditor. The SelectedItems property should be bind to a Source, not via the DataContext. Also to update your collection in ViewModel you should handle the CollectionChanged event of ObservableCollection and perform the needed actions. Please let me know If I am missing something about your scenario.
Please let me know if you require any further assistance on the matter.
Thanks.. for your support. and now I am on track and one thing more that,while holding Shift key all data should be select with in this drop down(using check box). Because now its not working with Shift key. Is there any additional code we have to add there???????. Please let me suggest for that.
Thanks for your quick reply. But we don't want to select all Items while using Shift Key. Suppose We have 10 Items and if we checked Fourth Number of item and while pressing Shift Key If we select Eight Number of Item At that point, Number between Four to Eight should be select.Any help for that??
Thanks
I have been looking into the functionality that you are looking for and I created short sample application, based on your scenario to show you how you can implement it. Basically in the attached sample application I handled KeyDown and SelectionChanged events of XamComboEditor. I used a bool variable to determine whether the Shift Key was pressed or not. In the handler of SelectionChanged event I check whether adding or deleting items from the collection. If adding item I check while Shift key was pressed. If it is pressed I get the index of first selected item and the index of last one. Then I loops into the collection between first and last index and set IsSelected property to True for each item.
Please let me know if you need any further assistance on the matter.
I am just checking if there is anything else I can do for you.