Is it possible to remove and move a row of listbox on itself? - windows-phone-7

Just like the UITableView on iphone.
users can remove or move a row on UITableView.
There is only one button to switch the UITableView to editing mode.
but for listbox on wp7 , I need 3 buttons, one for removing the selected row, one for moving the row up, one for moving the row down.
Welcome any comment

The Windows Phone ListBox doesn't support these features out of the box, but it would be possible to add them yourself using a DataTemplate.
Here's a blog post about creating a custom DataTemplate for your ListItems.
At a high level, you'll need to create a template that contains:
Enter edit mode button
Delete button
Sort up/down buttons
Then in your code, you'll need to toggle the visibility of the delete and sort buttons, as well as handle user clicks on each of the buttons. Doable, but a fair amount of work.
In my opinion, a better option would be to use a approach that's different from what you might be used to but is more familiar to Windows Phone users: the ContextMenu. This control allows you to pop up a menu when the user performs a long touch (tap-and-hold) on an item.
Here's a good tutorial about incorporating this control into your app.

Take a look at re-order ListBox here. It shows how to retemplate the ListBox.
For removing on item, you just need to remove its data source item. See how to use ObservableCollection.
If you want to show effect when an item is removed, use Event Triggers for the Unloaded event.

Related

Expand and Collapse Standard Cocoa Controls on a View

I want to do something similar to the calendar.app info panels, take a look at the pictures.
Here you can a see a very simple and compact info panel, but if you click on the last row "Add Notes, Attachments, or URL"....
It expands to show additional fields.
How can I achieve this functionality of expanding and collapsing additional controls ?
Can this been done through interface builder and constraints ?
Take a look at Apples example code for NSStackView,
https://developer.apple.com/library/mac/samplecode/InfoBarStackView/Introduction/Intro.html
It will show you how to implement views that collapse and disclose. In Apple's example they do everything programmatically using auto layout constraints, although you could move some of the work to IB if you wanted to.
I would create the view you want and add a tracking area to monitor when the mouse enters and clicks (using -mouseDown: notification) the "Add attachments, notes, URLs" section and use the stack view method to disclose the details.

Scrollable when keyboard displayed?

I have a registration form on my layout grid, made out of a stackPanel. Textboxes are taking most of the screen (800px) along with a button. When user is positioned in one of the text boxes, keyboard covers almost half the screen and in order to access boxes below, they first have to click somewhere blank to remove the keyboard and then click another box. It isn't possible to scroll down.
I want to enable same behaviour like when editing name in contacts, but didn't manage yet. How to achieve this?
Try wrapping it into a ListBox or a ScrollViewer (probably easier), like so:
<ScrollViewer>
...
</ScrollViewer>
Also, check to make sure you don't have the same problem described here.
I'm not a WP7 developer but here's what I do in Android and iOS and you may get a hint of what to do.
I wrap my forms in a Scrollable View. This gives easy scrollable features to users without the need of anything else.

Change ListBox selected item on finger tap, not on finger release

The Windows Phone ListBox control changes the selected item when the user releases the finger after having tapped the item. I would like the selected item to change as soon as the user taps the item, without waiting the finger to be released. Is there any way to achieve this?
Actually what I want to do is to handle the ListBox "Hold" event to do something on the selected item. Currently, two taps are needed (one short tap for selecting the item, and another one for the hold behavior), and I would like one tap to be enough bor both changing the selected item, and the hold behavior.
Use the Hold gesture instead.
If you need a context menu, use the ContextMenu from the [Silverlight Toolkit].

Windows Phone 7 - Move Content above Keyboard

I have page containing 4 textboxes and a button. The content is within ScrollViewer. When user goes to the last textbox, the button below it is 50% visible. So, to click it, user has to click on non-focusable area to hide the keyboard and then click on button.
Is there any way to move the ScrollViewer up? Or move the content up so that the button below focused textbox can be seen 100%?
The solution is to remove the buttons on the page and replace them with buttons in the ApplicationBar as this is always viewable below the SIP.
If this is not a solution you can implement (from a design view-point there is no reason to not do this but sometimes these decisions come from elsewhere) then you could look to use the ScrollToVerticalOffset method to try and bring the desired item into view.
I would suggest you read Alex Sorokoletov's article on how to transform the view. It might be of help for your problem.

Silverlight 2.0 RC Drag and drop ordering of a ListBox

I am trying to give a ListBox drag and drop ordering functionality and I have hit a wall. I got it to work when I specify the list box items in xaml but it does not work when I bind to a list it no longer works because the items are no longer of a listboxitem type.
I found this code http://blog.dobaginski.com/josh/?p=52 that allows me to get the underlying ListBoxItem but I can't get the mouse move event to fire.
I have went through other tutorials but have not been able to find one that deals with a ListBox. Has anyone done this with a ListBox.
The events I am using are SelectedChange, MouseMove, and LeftMouseButtonUp (I think that name is right). I am not using LeftMouseButtonDown because I couldn't get it to fire.
As far as i know you cannot get at the listbox item container when using data binding. YOu could in Beta 1.
You also cannot set a mouse event handler in the style, you must use a data template, just so you know.
You will likely have to use the mouse move event from a parent element, probably the UserControl or main layout control that hosts the listbox.
State changes and animations need to be in the style though so... you still cant get at the listbox item, just the element inside it in the data template.
Oh and if doing drag and drop HitTest is now protected so that will make the Drop harder.
since today you can download the final 2.0 version of Silverlight with some add ons, check the Scott's web log
I've been trying to do the same thing in WPF,
but have only found many buggy implementations.
One person has guided me towards the blog of Beatriz Costa,
and from what I remember she's one of those rare geniouses,
so I suggest you read that as well... I know I will
Blog of Beatriz Costa

Resources