WP7 how to know when popup shows up? - windows-phone-7

I'm using popup to show my user control. I want to detect when the popup is REALLY shown up on the screen, then I show the progress bar, do some work, then hide the progress bar
MyDialog dialog = new MyDialog();
myPopup.Child = dialog;
myPopup.IsOpen = true;
dialog.progressLoading.Visibility = Visibility.Visible;
Thread.Sleep(3000)
dialog.progressLoading.Visibility = Visibility.Collapsed;
However, I realize that IsOpen = true doesnot show the popup instantly. The fact is that I must wait 3 seconds for it to show up.
How to know when popup shows up ?

Related

Showing a dialog on top right corner

I want to create a dialog with a custom layout and no title. Also, the dialog should open on the top right corner of the screen. Here is the screenshot of what I want.
In xamarin.iOS is something like PopOverViewContainer. May it's in Android the same.
Maybe by changing the gravity of the dialog using the WindowManager Attributes property:
Android.App.AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
AlertDialog alertName = builder.Create();
alertName.SetTitle("Warning...");
alertName.SetIcon(Android.Resource.Drawable.IcDialogAlert);
alertName.SetMessage("This is a warning message");
alertName.SetButton("OK", (s, ev) =>
{
return;
});
alertName.Show();
var window = alertName.Window;
var wlp = window.Attributes;
wlp.Gravity = GravityFlags.Top;
wlp.Flags = WindowManagerFlags.DimBehind;
window.Attributes = wlp;
You should be able to change the gravity parameter and the flags (which currently stops the background to the dialog from dimming
I have used below code to achieve my requirement.
Window window = dialog.Window;
WindowManager.LayoutParams wlp = window.Attributes;
wlp.Gravity = GravityFlags.Top | GravityFlags.Right;
window.Attributes = wlp;

list picker in popup windows phone

I am using a list picker in popup. But when I click on list picker, its full mode opens behind popup. How can I make my list picker full mode window to appear above popup.
MY list picker is in the user control called WindowsPhoneControl1
Popup Mypopup = new Popup();
Mypopup.Height = 300;
Mypopup.Width = 400;
Mypopup.VerticalOffset = 100;
WindowsPhoneControl1 Mycontrol = new WindowsPhoneControl1();
Mypopup.Child = Mycontrol;
Mypopup.IsOpen = true;
i didn't find a solution
thank you
Try defining the Popup in XAML.
such as so:
<Popup IsOpen="true" Name="MyPopup" Height="300" Width="400" VerticleOffset="100"/>
Make sure IsOpen is true, then try to right-click on the ListPicker and choose it's order: bring-to-front.
I know it's simple, but I didn't see you mention trying it, so give it a shot!

Page Transitions not working for ForwardIn upon navigation

I have multiple pages in my WP7 app and I move in and out of apps by selections made during usage of the app. it is a data heavy app, but i'm not doing anything else but fill up the control by using its own ViewModel.
The ForwardIn transition animation fails to show up - which results in an ugly black screen pause for about 1.5 seconds and the page suddenly seems to popup. I have a white background in some pages so after appearing the phone tries to adjust the brightness automatically, which looks bad too. is there anythign specific I need to look out for?
Is there a way I can preload the page before navigation so that it happens smoothly, I'm using the performance progress bar in the previous pages to load data anyway. are there any ways to profile this page load so that I can check what took the most time.
I have seen this effect a lot when binding to lists. What I do is delay the binding until after the navigation/animation is complete. I usually show a progress bar after animation completes, wait about 50ms on a background thread to allow the progress bar to update it's UI and then bind to the list and hide the progress bar.
Here is the code I run when the animation completes:
progressBar.IsIndeterminate = true;
progressBar.Visibility = Visibility.Visible;
SynchronizationContext context = SynchronizationContext.Current;
Thread t = new Thread(() =>
{
/* Allow the UI to catch up */
Thread.Sleep(50);
context.Post((state) =>
{
list.ItemsSource = dataSource;
/* Hide the progress bar */
progressBar.IsIndeterminate = false;
progressBar.Visibility = Visibility.Collapsed;
}, null);
});
t.IsBackground = true;
t.Start();

Control press "back button" and disable close the application using a dialog for confirm - wp7

I need show a simple dialog with the question : 'Do you want to exit the application?' YES or NO.
This dialog will be shown when the user presses the back button of the device.
I know how I can show this dialog , but I don't know how to disable the back action: close app.
It's always closed.
If I understand you correctly, you want to display a confirmation dialog when the user clicks the back button on the main page of your app to ask whether they really want to exit. If the user selects Yes the app exits, otherwise you cancel the back navigation. To do this, in the MainPage class constructor hook up an event handler
MainPage()
{
BackKeyPress += OnBackKeyPressed;
}
void OnBackKeyPressed( object sender, CancelEventArgs e )
{
var result = MessageBox.Show( "Do you want to exit?", "Attention!",
MessageBoxButton.OKCancel );
if( result == MessageBoxResult.OK ) {
// Do not cancel navigation
return;
}
e.Cancel = true;
}

how to close the CameraCaptureDialog dialog automatically after taking a photo using C#

I am doing a work that scans the barcode and gets the information behind it under windows mobile 6.5 and .net compact framework 2.0, using CameraCaptureDialog class to capture a picture from the phone camera, this is my code:
CameraCaptureDialog cameraCaptureDialog = new CameraCaptureDialog();
cameraCaptureDialog.Owner = this;
cameraCaptureDialog.Title = "";
cameraCaptureDialog.Mode = CameraCaptureMode.Still;
cameraCaptureDialog.InitialDirectory = dir;
cameraCaptureDialog.Resolution = new System.Drawing.Size(640, 480);
cameraCaptureDialog.DefaultFileName = "CodeBar.jpg";
if (cameraCaptureDialog.ShowDialog() == DialogResult.OK && cameraCaptureDialog.FileName.Length > 0)
{
curFileName = cameraCaptureDialog.FileName;
cameraCaptureDialog.Dispose();
}
//deal with CodeBar.jpg
the question is, during my code running, I have to press the capture button on the cameraCaptureDialog, then press the back button to return to my program to deal with the captured file, this operation needs to press 2 buttons, for user convenience, I want the cameraCaptureDialog to close automatically after the user pressed the capture button, how can this be done? as I know, when ShowDialog() method is called, cameraCaptureDialog won't return until the back button shown on the dialog, so I could do nothing before manually close the cameraCaptureDialog and the ShowDialog() method returned DialogResult.OK

Resources