Focusing on textBox ScrollViewing issue- Windows Phone 7 - windows-phone-7

Ok I write Windows Phone 7.5 application in which I have several textboxes in a single page.
I made a ScrollViewer and inside I have a Grid and the textBoxes are inside the Grid.
I want to make it so that when I press enter keyboard button in the textbox I will focus on the next textBox.
So I made events in which I check whether enter button is clicked and if it is I focus on the next element, but when I focus on textBox which is even lower than the normal window and you have to scroll down to see it, it actually focuses on it but doesn't displays it and the screen stays on the last marked textbox.
Is there a way to fix that? Here is how I do it:
private void txtUsername_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
txtPassword.Focus();
}
}

Related

Input lag in Textboxes inside a ListView

I am working on a UWP app that has a view which is, sort of, like excel. The user can input data on text fields, which are inside a ListView. Upon scrolling, more items are added in the ListView and hence more textboxes come into play.
The problem that I am facing with this is that the typing on these textboxes has a lot of lag. I was using caliburn micro mvvm framework and thought it is slowing down the app (which it was, the navigation mostly) so I removed it but there is no effect on the typing lag.
Does anyone have experience with this?
You are calling code in TextChanging- this will fire every time a user enters or deletes a character from the TextBox. Not good. Unfortunately TextChanged will also do the same thing.
You want to fire your code when the user hits the enter key on KeyUp
https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.uielement.keyup
private void myTextbox_KeyUp(object sender, KeyRoutedEventArgs e)
{
if (e.Key == VirtualKey.Enter)
{
// the user has pressed enter and is done entering text, do something here
}
}

change ListView item image at runtime (firemonkey)

I need the ability for a user to press and set an ListView item's checkbox independently of clicking on the item. If they press on the checkbox I will add/remove the checkmark and take some action. If they press on the item text I can take another action.
I can do this with a ListBox no problem with built in functionality. I can't figure out how to do it with a ListView. How is it done?
I can put the following code in the ListView1ItemClickEx to know when the user is clicking on the image. Maybe I can just change the image to a checkmark?
if (ItemObject->Name == "I") {
ShowMessage("Item Image clicked");
}
But I don't know how to change that particular items image (e.g. I could just toggle between a checkmark image and an unchecked image) at runtime.
The picture below is for clarity. Clicking anywhere in the red box will change the items checkbox. For the ListBox clicking anywhere in the blue box will fire the OnClick event and not change the checkbox. I want that same behavior in the ListView.
Ok, Remy answered this related question and it helped me solve this issue. Now I can make the ListView have a checkbox that functions like that of the ListBox. I do it by toggling the item image whenever the user presses (or clicks on) the image area of an item.
When the user clicks an items image I trap it (per Remy's code in the ListView1ItemClickEx event) and toggle it from 0->1 or 1->0 in a vector at reference ItemIndex (e.g. myVector[ItemIndex] = 0) and then I completely rebuild the ListView (clear it and build from scratch).
I thought I'd have to remember where in the list I had scrolled down to and after refreshing the ListView I'd have to scroll to that point in code - but, that isn't the case. I don't know why but after the refresh I'm still at the point in the list where I clicked an item image. It makes it work and feel exactly like a check box.
It works great in iOS, Android, and Windows.
p.s. I forgot to mention that you need to treat any Header's like they are items in your vector that keeps up with each items' image (0 or 1). Otherwise adding headers gets you out of sync and clicking an item's image will toggle some other item's image.

JavaFX capture events of a disabled button

In my application I have a multi step form wizard in which
the next button is disabled unless all the required fields are entered.
Some fields require extra validation such as the directory picker,
for which I have to check whether the directory exists or not.
To ease the user experience I need to show an "Invalid directory" tooltip
next to the directory text field.
I would like to show the tooltips when the user tries to click/enter the disabled
next button.
Is it possible to capture events performed on a disabled button in JavaFX?
public void nextEntered(Event event) {
Button button = (Button)event.getSource();
if(button.isDisabled()){
validate(currentTab);
}
}
I had a similar problem where I wanted to show a tooltip of a disabled field's value when the user moused over that disabled field.
I ended up putting a blank label over the disabled field and attaching a mouse event to that.
In the case of a button, you can just give the dummy label mouse transparency when the button becomes enabled so the user can click the button.
(You might even be able to bind the label's mouse transparency property to the button's enabled property but I'm not sure.)
I know this was asked a year ago but maybe it will help someone else.

Remove background color from buttons in Listbox (Windows Phone)

I have a function connected to a buttonclick in i Listbox. It sets the background color of the selected button. The problem with this is that i only want one button at a time to act as selected. With this solution every button clicked gets the green background... how can i reset the buttons that are not selected to a black background?
private void SettingsChangeRegionButton_Click(object sender, RoutedEventArgs e)
{
Button clickedButton = sender as Button;
clickedButton.Background = new SolidColorBrush(Colors.Green);
RssStream choosenStream = GetRssStreamFromName(clickedButton.Content.ToString());
}
If you want a button to be green while it is being pressed you should change the color which is used as the background in the Pressed state.
If you just want to highlight which is the currently selected item in the list(box) then you need to change the styling of the item in the Selected state.
Sorry, if you know this but to pre-empt your next question: You can change a template by selecting an item in the objects and timeline window in blend and selecting "Edit Template" (or "Edit Additional Templates" as appropriate).

WP7 ListPicker on Popup causing Back button problems

I am using the WP7 Tookit ListPicker (Feb release) on a Popup Control. I have trapped the Back button so I can close the popup.
If I press the back button while the ListPicker is open in popup mode, my back button event handler is firing before the ListPicker handles it so both the ListPicker and my popup are closing.
One way I thought of handling it was to check and see if I have any ListPickers on the popup that are open and if so close the and cancel the navigation (the controls on my popup are added dynamically so I have to enumerate through the popup child controls to check) but I can't find a way of seeing if the ListPicker is Open or Closing it.
So my question is a) is there a way of handling this in the back button handler and if not b) how can I check if a ListPicker is Open.
In your popup control's BackKeyPress callback add the following check:
if( myListPicker.ListPickerMode == ListPickerMode.Normal ) {
// Close popup
// Cancel navigation
e.Cancel = true;
}
When ListPickerMode is Expanded or Full the ListPicker will catch the back key pressed event and close itself.
EDIT:
According to #SteveChadbourne's comment the following worked:
if( myListPicker.ListPickerMode != ListPickerMode.Normal ) {
// Close the ListPicker
myListPicker.ListPickerMode = ListPickerMode.Normal;
// Cancel navigation
e.Cancel = true;
}

Resources