- How to force tombstoning for debug in Mango?
In order to test your tombstoning code you can force your application to be tombstoned instead of kept in memory during debugging. To do this, just open your project properties panel, click the debug tab and check Tombstone upon deactivation while debugging. - How to remove a Page from backStack in Mango?
Sometime (ex. LoginPage, DisclaimerPage) it is useful to change the back navigation normal behaviour. Before Mango the only way to change the back navigation was to use a work around like generate a QuitException (see http://www.imaginativeuniversal.com/blog/post/2010/08/22/How-to-Quit-a-WP7-Silverlight-Application.aspx). Now with Mango you can use the useful NavigationService.RemoveBackEntry() method. Unfortunately, because the backStack is a LIFO, it is possible to remove only the top entry, that is the previous page entry. So the best way to remove a page from the backStack is to use that method just in the overridden OnNavigatedFrom method of that page itself.protected override void OnNavigatedFrom(NavigationEventArgs e) { this.NavigationService.RemoveBackEntry(); //remove itself from the backStack base.OnNavigatedFrom(e); }
In particular for a LoginPage (if it is not implemented as a popup window or a section of the MainPage hidden/visible properly), if the login is not always requiìred but depends from some configuration settings (ex. once a day login) it is convinent to call first the MainPage, check if the user is already authenticated in the _load method and if not call the LoginPage. A convenient flag can be used to discriminate in the OnNavigatedFrom method of the MainPage if the LoginPage is called or not and so eventually use the NavigationService.RemoveBackEntry().
void MainPage_Loaded(object sender, RoutedEventArgs e) { if (!DataSourceManager.LoginDataSource.User.Authenticated) { //if the user is not authenticated, let's go to the LoginPage NavigationService.Navigate(new Uri("/LoginPage.xaml", UriKind.Relative)); toLoginflag = true; } else { Main.Visibility = System.Windows.Visibility.Visible; } } protected override void OnNavigatedFrom(NavigationEventArgs e) { if (toLoginflag) { this.NavigationService.RemoveBackEntry(); //remove itself from the backStack } }
- Be careful when debugging a CameraCaptureTask with a Windows Phone device!!
You must disconnect the device from the PC if you want to try the launcher for taking a picture from your program. Otherwise, when you call the Show method of that task, the registered cameraTask_Completed event is suddenly rised with a PhotoResult.TaskResult ==TaskResult.Cancel .
- Mango provides a build in progressbar shown in the system tray!!
No need to use the PerformanceProgressBar of the toolkit anymore.
You just have to add in App.cs:public static ProgressIndicator progInd = newProgressIndicator();
and in the constructor add:
progInd.IsIndeterminate = false; progInd.IsVisible = false;
Then add in the page where you need the progressBar a method like this:
privatevoid RunProgressBar(bool value) { if (value) { App.progInd.Text = LocalizedStrings.GetString(“Loading”); App.progInd.IsIndeterminate = true; App.progInd.IsVisible = true; SystemTray.SetProgressIndicator(this, App.progInd); } else { App.progInd.Text = null; App.progInd.IsIndeterminate = false; App.progInd.IsVisible = false; SystemTray.SetProgressIndicator(this, null); } }
- How you can easely know how a page is navigated (for example if it is called for the first time or from a back)?
You can override the OnNavigationTo method and test its NavigationEventArgs parameter comparing it with the appropriate value of the NavigationMode emumeration. For example:if(e.NavigationMode == NavigationMode.New) { //it is called for the first time
Remember that the OnNavigationTo method is called just after the page contructor and befor the possible MyPage_Load method, if you define that new RoutedEventHandler in the page contructor
this.Loaded += newRoutedEventHandler(MyPage_Loaded);)
- How you can wrap a text longer than a line in the text of a CheckBox?
You must override TextBox’s style inside the CheckBox tag:<CheckBox x:Name="checkBoxMergeAudio" IsChecked="{Binding IsMergeAudio, Mode=TwoWay}" Margin="0,0,0,0" Click="checkBoxMergeAudio_Changed" ClickMode="Release"> <TextBlock TextWrapping="Wrap" Text="{Binding LocalizedResources.MergeAudio, Source={StaticResource LocalizedStrings}}" /> </CheckBox>
- How to play an audio recorded with Phone 7 off somewhere else (ex. on a PC)?
If you record voice with the Microsoft.Xna.Framework.Audio.Microfone, it just gets a PCM encoded stream of samples. Only if you use the DynamicSoundEffectInstance on the Phone 7 code the PCM encoded stream can be played also without the wav header. So, if you want to send this audio stream off somewhere else (ex. to PC Server using a web service) to be played later, it needs a proper header otherwise no PC audio player can read it. Here you can find useful code: http://damianblog.com/2011/02/07/storing-wp7-recorded-audio-as-wav-format-streams/
If you need to merge more audio in a single one, you need to recontruct the wav header followed by the data content of each sigle audio file. Here you can find a useful link if all the wav files have the same coding: http://www.codeproject.com/Articles/15187/Concatenating-Wave-Files-Using-C-2005 - Remember to escape the string of URI data passed in a query when you want to Navigate to an other page.
If any of your query strings contain characters that are considered invalid in a Uri what you’re doing will fail, as you’ve discovered. You need to use Uri.EscapeDataString to escape any illegal characters first.
The escaped strings are automatically unescaped when you read them using NavigationContext.QueryString, so there’s no need to call Uri.UnescapeDataString explicitly.
For example:StringBuilder sbPage = new StringBuilder("/").Append(baseUri); sbPage.Append("?ID=").Append("&asset=").Append(<strong>Uri.EscapeDataString</strong>(asset.<em>Description</em>)); NavigationService.Navigate(new Uri(sbPage.ToString(), UriKind.Relative));
-
Unisciti a 146 altri iscritti
Categorie
Supporta questo Blog
Translate
-
Articoli recenti
- Come scaricare gratuitamente da YouTube, sul proprio PC, tutti i video/audio presenti in una playlist 30 gennaio 2023
- Come inserire simboli musicali in un documento Word 24 gennaio 2023
- Come cambiare le coordinate di accredito della pensione nel sito dell’INPS 16 gennaio 2023
- Come utilizzare la Carta Sanitaria come Carta Nazionale dei Servizi (CNS) in alternativa a un accesso tramite SPID/CIE: può essere anche un agevole metodo per operare per conto di una persona anziana o comunque incapace di utilizzare servizi offerti online 12 gennaio 2023
- Cosa fare se, connettendo un PC all’hotspot Wi-Fi del proprio smartphone, su quest’ultimo si perde la connessione a Internet, benché questa venga fornita al PC 3 gennaio 2023
Articoli in evidenza
Archivi
Classifica Post
- Come sapere se un rubinetto (e.g. per lavatrice o del gas) è aperto o chiuso?
- Come recuperare il PIN/PUK della propria Carta d'Identità Elettronica (CIE) e poi leggerla con un lettore NFC
- TicketOne: cosa fare se non si riesce ad acquistare un biglietto in quanto viene indicato che "Il codice fiscale inserito risulta già registrato"?
- Come modificare o cancellare un beneficiario/contatto precedentemente salvato in un sito della banca (e.g. BNL, IngDirect, Intesa SanPaolo)
- Drawing UML 2.5 diagrams with Visio 2016 (even with the Standard edition)
- 18app: come fare se non si riesce più ad autorizzare un accesso con PosteID
- Come collegare un telefono a un modem con SIM per ricevere/effettuare telefonate tramite un apparato telefonico multifrequenza
- Facebook problem: it is still impossible to move to another album a photo if uploaded in one post along with other images
- Cosa fare se una lampadina led a filamento non si spegne completamente anche mettendo l'interruttore ad OFF
- Da un solo smartphone come riuscire a gestire più SPID, anche ciascuno associato a persone differenti
Foto su Flickr
Annunci