Keyboard overlaps popup in wp8 - windows-phone-8

I am developing a Login screen in which the user needs to introduce their data and then submit them.
Considerations which I had: I have thought about using a Page, but eventually I rejected the idea because if I put Login page before the MainPage, then if I go back from MainPage, then it would go to Login page, which is not what I want. And if Login page were after MainPage, then if I execute for instance the app for first time, without being logged in, if I press back, then it would go to MainPage which I don't want as well.
The problem: I decided finally to use a Popup. At the moment looks perfect, but when I want to use a textbox, the Keyboard overlaps that textbox, and what I want is to move the Popup upwards just like a normal page. I don't know if is that possible, otherwise I am willing to hear some alternatives.
Thank you in advance.

In WMAppManifest.xml remove the property of Navigation Page and in you App.xaml.cs you have something like:
private void Application_Launching(object sender, LaunchingEventArgs e)
{
LoadDefautPage();
}
void LoadDefautPage()
{
if (StartForFirstTime)//tombstone local variable
{
if (!IsLoggedIn)//flag save it in IsolatedStorageSettings
{
RootFrame.Navigate(new Uri("/LoginPage.xaml", UriKind.Relative));
}
else
{
RootFrame.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
}
StartForFirstTime = false;
}
}
finally remove Back Entry in MainPage:
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
while (this.NavigationService.CanGoBack)
{
this.NavigationService.RemoveBackEntry();
}
}
It's just an idea, let me know how it goes (:

Related

Is it possible to temporarily postpane displaying an AppBarButton's affiliated Flyout?

I've got a Flyout embedded within an AppBarButton like so:
<AppBarButton x:Name="appbarbtnOpenPhotosets" Icon="OpenFile" Label="Open Existing Photoset[s]" AutomationProperties.Name="Open File" Tapped="appbarbtnOpenPhotosets_Tapped" >
<Button.Flyout>
. . .
</Button.Flyout>
</AppBarButton>
I want to, under certain circumstances, first present the user with an opportunity to rename a file prior to seeing the Flyout. I tried seeing if that would work like this:
async private void appbarbtnOpenPhotosets_Tapped(object sender, TappedRoutedEventArgs args)
{
// Want to conditionally postpone the operation
bool myBucketsGotAHoleInIt = PhotraxUtils.GetLocalSetting(CAINT_BUY_NO_BEER);
if (myBucketsGotAHoleInIt)
{
MessageDialog dlgDone = new MessageDialog("Can you see me now?");
await dlgDone.ShowAsync();
args.Handled = false; // <= adding this made no difference
}
}
This works, in that I see the "Can you see me now?" dialog, but that prevents the Flyout from flying out. A Flyout that doesn't fly out is no more useful than a flying squirrel or fish that doesn't motate through the air.
So how can I temporarily suppress my flyout but then call it forth? The Flyout does not have an Open() method...Is there some other way to invoke it?
Flyouts attached to Buttons open automatically when you click the control.
If you don't want it to open automatically, you need to attach it to another control.
Example taken from official documentation:
<!-- Flyout declared inline on a FrameworkElement -->
<TextBlock>
<FlyoutBase.AttachedFlyout>
<Flyout>
<!-- Flyout content -->
</Flyout>
</FlyoutBase.AttachedFlyout>
</TextBlock>
Then you can show the Flyout whenever you want, calling FlayoutBase.ShowAttachedFlyout() and passing the FrameworkElement casted value of your control.
FlyoutBase.ShowAttachedFlyout(frameworkElement);
So, in your case:
async private void appbarbtnOpenPhotosets_Tapped(object sender, TappedRoutedEventArgs args)
{
// Want to conditionally postpone the operation
bool myBucketsGotAHoleInIt = PhotraxUtils.GetLocalSetting(CAINT_BUY_NO_BEER);
if (myBucketsGotAHoleInIt)
{
MessageDialog dlgDone = new MessageDialog("Can you see me now?");
await dlgDone.ShowAsync();
// New code
FlyoutBase.ShowAttachedFlyout((FrameworkElement)sender);
}
}
If you can't change the control, you should able to use the code I posted with Buttoninstead of TextBlock. I'm not sure about this, but you can try.

winrt backspace in Settingsflyout

I create simple SettingsFlyout panel following this example of microsoft http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh872190.aspx
Everything is fine, but how can I make backspace go back to settings panel?
You can doing what you want if you edit the control. Use Blend will help you so much. Right Click => Edit Template.
This work for me:
In code behind
private void settingsAbout_KeyDown(object sender, KeyRoutedEventArgs e)
{
if (e.Key == VirtualKey.Back)
{
SettingsPane.Show();
}
}
in xaml
KeyDown="settingsAbout_KeyDown"

How do you debug PhotoTaskChooser in WP8 on a physical device?

I have the simplest possible app. The UI is a page with nothing on it but a Tap method on a grid.
The code-behind looks like this...
public partial class MainPage : PhoneApplicationPage
{
private PhotoChooserTask _photoChooser;
// Constructor
public MainPage()
{
InitializeComponent();
_photoChooser.Completed += OnPhotoChosen;
}
private void OnTap(object sender, System.Windows.Input.GestureEventArgs e)
{
_photoChooser.Show();
}
private void OnPhotoChosen(object sender, PhotoResult result)
{
}
}
Now, what happens is that when I debug this application ON THE DEVICE, it briefly shows the photo chooser but then immediately deactivates...I assume because the photo chooser has taken focus. But from everything I've read, this should NOT be happening because the PhotoChooserTask's Completed event has been wired up in the constructor for my page, which should explicitly prevent my app from deactivating when the photochooser is active.
What's even more confusing is that the app seems to work when I'm NOT debugging it. Once I've selected a photo in this scenario, my app regains the foreground.
Is this a bug with the debugger or something else?
So it turns out the solution is to debug using "Start New Instance" in Visual Studio rather than just hitting F5.

NavigationService remove complete back navigation

Using NavigationService.RemoveBackEntry() I can remove one entry from the navigation stack. Is there a convenient way to remove all back navigation items in my app (scenario: I have a sign-up procedure which consists of multiple pages, and after successful registration I do not want the user to navigate back to the registration steps).
It's not that inconvenient to do that with RemoveBackEntry:
while(NavigationService.CanGoBack)
{
NavigationService.RemoveBackEntry();
}
Or use this, a single line code
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
while (NavigationService.RemoveBackEntry() != null) ;
}

Windows Phone: How to Navigate another page which is using DispatcherTimer?

I have two pages Main.xaml which includes only a button and another page timer.xaml which includes a timer. After pressing the button in the main page I want to go to the another page and start timer. I am using following code:
enter code here
**Main Page:**
private void Start_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/timer.xaml", UriKind.Relative));
}
**timer Page:**
public Page1()
{
InitializeComponent();
dispatcherTimer.Interval = new TimeSpan(0, 0, 1, 0, 0);
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Start();
counter=0;
count.Text = counter.ToString();
}
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
counter++;
count.Text = counter.ToString();
}
I can not see time in the timer page however, after pressing the button it will navigate to the timer page correctly but I can not see updates in my timer page. I am debugging my code and it seems that DistpacherTimer() works correctly but my timer page does not update. Do you know how can I fix this problem?
Finally, I could find the problem. the code that you can see above was not whole code that I have written. Actually, in my real code I was sending a list <> from main page to timer page. Passing data from one page to another page is a little tricky. My main problem was that I did not send the data from main page to timer page in correct way, so that caused problem. Thus, there was nothing wrong with my DispatcherTimer() class or Event handler.
In other words, the code above works well if you do not pass data (e.g. list, array and so on) from a page to another page in a wrong way.