My Search Contract populates a SearchContractResultsPages resultsList with objects, however when I try to select an item (which opens other page and passes the selection as a navigation parameter), the first item is always selected and passed as the parameter. I simply have no idea what to do to fix this, or what code needs changing, the resultsListView.SelectedItem is always the item opened, no matter what I actually select. The selection logic is carried out on the DoubleTapped event.
I don't know what code to post, so if anyone has any ideas, I will happily post I relevant parts you need to see.
Bit of a cop-out before I answer, but it depends...
If you are navigating to another page on SelectedItemChanged, the selected item should probably already be the correct one and you can use that as your navigation parameter. If this isn't working we will need to see more (come) code.
If you have an ItemClick event handler on the list view, you should use e.ClickedItem to get the correct reference back. Again, if this is what you are doing and it isn't working, we will need to see code.
Ah, I see you are switching selections on Double tapping the item. This could be the cause of your problem. Double-clicking to select is not one of the usual ways to select an item in a list. You should probably stick with the "small swipe" to select, as virtually all other apps in the ecosystem do. Not only will this let you verify what selection you have made before doing anything with it, but it will not confuse users since they're already used to the paradigm.
Related
I have an ObservableCollection that is wrapped by a ListCollectionView.
The ListCollectionView is displayed in a grid (XamDataGrid).
When I add items to my observable collection those items are exposed by the ListViewCollection sorted in the order defined by the SortDescriptions property.
Here's the problem. I would like new items to appear at the bottom of my grid even though the existing ones are currently sorted. Next time the user sorts (by clicking at the column header) the new items should be sorted.
I'm struggling to find a solution to this problem. Anyone's had a similar issue?
Solution A: Manage the sorting yourself behind the scenes
Easiest thing to do here is sort the data behind the scenes (you can use LINQ for that), then assign it to the grid without the sort descriptions. Then as you add items, they'll just appear at the end of the collection. When you click on a header, intercept that and sort yourself accordingly.
Solution B: Add another SortDescription
Another approach is to add another property to your data and create a primary sort on that field first, then by what you actually want to sort on. For instance, you could add a boolean called existedBeforeSort. If you can't modify your model, you can do it via an extension where you store the actual value in a dictionary keyed on the object itself. (That's sort of how DependencyProperties work, but this can be for any object since you're managing the storage.)
Now, in the grid, as you click a sort header, the first thing you do is set the existedBeforeSort property on all items to true. Since your first SortDescription is based on that field, followed by the sort descriptions generated by clicking on the headers, all newly added items will appear at the bottom as you wanted.
The trick to this second approach is making sure as you click on sort headers, you manually make sure your SortDescription based on your existedBeforeSort property is always inserted first. In essence, you're hijacking the implied SortDescriptions and injecting yours to supersede theirs. Shouldn't be too difficult though.
Hope this helps!
I typically use the control #Edit.Toolbar(Content, actions:"edit,new,remove,instance-list") on the items themselves. Then the user can edit the entire list from click the button on any of the items. Logically, it would make more sense for them to click the instance-list button from the ListContent
In previous versions of 2SXC, the user could hover over the DNN black and white pencil icon and click "Edit List" which made a lot of sense. This control is not available in newer versions of 2SXC so they have to edit the list by going to any of the list items.
I tried using 'instance-list' in the ListContent controls but it doesn't seem to be available there. Is there a way to give the instance-list control to the ListContent control?
I have a scenario where this is especially important. On some lists that I have, I prefer to force my user to use the Edit List to enter a list title but also edit content from the list interface rather than me putting the around every link.
The instance-list is the correct button, just ATM it doesn't offer the additional buttons. I believe others have requested it as well, we just haven't found time to implement it. You can open a new issue, but code-contributions would work even better :)
I have a strange issue with a combobox. The control is bound to a collection that contains a duplicate item, albeit with different case.
They are populated in the list, via databinding, as such:
Babu
BABU
Within the application that I am creating, case is important and both items need to be displayed.
I have the selected item as BABU, yet when I open the combobox, the selectted item immediately changes to Babu without any further intervention from me. I am not handling the DropDownOpening event anywhere so there is no logic there that is causing this.
My suspicions are that it's to do with the databinding not liking what it see's as duplicate entries but I cannot be sure about this.
Has anybody experienced this before?
Open up the Designer code for that form and confirm that BABU and Babu are included in your autocomplete list for that combobox. This happened to me once where I fixed it on the form designer but it never synced up with the form designers code and it ended up containing old unwanted selections.
Also check out your autocomplete modes: http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.autocompletemode.aspx
I have a telerik combobox in mvc3 application and I want to prevent the user writing a value different from the list being loaded from the controller.
A thing that partial helped is to set the textbox input to be readonly but then:
1. The user can filter the list by the textbox.
2. The user can erase his selection.
Another thing that I thought about is: What the user types in the select is the value not the description, so I need it to prevent writing text different from the description while the value remains encapsulated.
Are you still looking to have the user be able to input custom text? If not you can use the DropDownList functionality as seen on this demo page.
If you still want the user to be able to type into the component but somehow have it aware of when they either misspell something, or type one character more than necessary, this can be extremely difficult. You would essentially have to have some clever JavaScript to be triggered with every key press and check the current value against a list. With users being pretty quick with typing, or their browsers being old, this can be very unreliable. Plus, a user can easily disable JavaScript at any time making this functionality obsolete.
I think your best options is to have it as is, where the user can type whatever they want. You can always have validation on the item they have typed and upon blur() or a POST (whatever fits your application) have a message appear to warn them of an invalid entry.
The desired functionality of the 'enhanced' combo box is a quick find method. Each item in the combobox has a ToString() method, such that they can be displayed in the drop down list. On clicking an item in the drop down list, the combobox's observers are notified of the selection.
Also, every time the typed text in the combobox changes, a list of "Candidates" is generated, made of all those items in the drop down list which contain the text typed in so far. Hitting enter takes you to the first candidate in that list, repeatedly hitting enter cycles you through the list.
I've implemented this functionality by deriving from ComboBox - I figured this made sense as I'm still functionally left with a combobox, it just has this "QuickFind" feature added. However, the logic to create the candidate list and cycle through it, whilst simple, isn't totally trivial, and would enjoy some testing.
However, as seen here it doesn't seem to be all that easy to test a ComboBox just by constructing it and prodding the extra routines I've added - it needs to exist on a form for it to behave the same way as it does in the application. This seems altogether too much effort to test a simple addition to a simple combo box!
Nothing in the code to cycle through the candidates is specific to my application however - I have created a general control that may be used in any number of contexts, the only requirement being that the objects in the combobox have a ToString() methiod, which is the same restriction placed on objects going into normal comboboxes anyway, and is guaranteed by C# .NET.
So, with testability in mind, where would you put the enhanced functionality?
As with the post you references: seperating the logic from the gui elements is also the solution here.
You should consider using a controller-like class which exposes a list of items which you can databind to your ComboBox' DataSource. The controller itself is responsible for maintaining this list.
So whenever you type a letter in the ComboBox you call a function on the controller, let's say UpdateList(string typedString). In this way you have seperated the logic of filling the list with 'candidates'.
Now you can easily write a number of tests which each call UpdateList() with different arguments and inspect the list of items afterwards. No GUI stuff needed to do the testing, you're only testing the algorithm itself.