- 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 timeRemember 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 166 altri iscritti
Categorie
Supporta questo Blog
Translate
-
Articoli recenti
- Come si fa a leggere il codice a barre di un prodotto e magari velocemente sapere quanto verrebbe comprandolo online? 7 dicembre 2025
- Come fare per migliorare le performance di alcuni programmi indicando loro di utilizzare la GPU più appropriata 30 novembre 2025
- Come usare funzionalità avanzate dello Snipping Tool/Strumento di cattura di Windows 11: sull’immagine tracciare a mano linee/figure geometriche/frecce e fare in modo che questi disegni vengano automaticamente migliorati graficamente (i.e. linea dritta, cerchio perfetto, freccia precisa) 30 novembre 2025
- Come fare a ricavare, da uno spartito stampato, un file modificabile, eseguibile e di cui salvare l’esecuzione in MP3… il tutto gratuitamente! 29 novembre 2025
- È sufficiente riaprire biblioteche ristrutturate per avere più Cultura e, direi, più educazione? … forse no! 21 novembre 2025
Articoli in evidenza
Archivi
Classifica Post
- Come sapere se un rubinetto (e.g. per lavatrice o del gas) è aperto o chiuso?
- Frattura biossea (tibia e perone) scomposta della gamba: istruzioni per l'uso
- Volkswagen: cosa fare se l'impostazione della sfera privata torna "Massima" e quindi i servizi in remoto vengono disattivati
- Telecamera IP di sicurezza Xiaomi Mi Home e configurazione per un salvataggio dei video anche su un hard disk esterno collegato alla rete locale
- Come riparare i telecomandi di poltrone e letti reclinabili
- Review e test dello scanner per diapositive REFLECTA - DigitDia 6000
- Come modificare o cancellare un beneficiario/contatto precedentemente salvato in un sito della banca (e.g. BNL, IngDirect, Intesa SanPaolo)
- Tramite il sito della banca, impossibile pagare l'F24 per le tasse TEFA e 3944 (rifiuti) inserendo le informazioni così come indicate nel modulo fornito dal sito della SORIS: come risolvere
- Monte Calvario a Villanova Mondovì (chiesa di Santa Caterina, santuario di Santa Lucia e cappella di San Bernardo): rifugio faunistico o sfruttamento indiscriminato delle risorse ambientali?
- Come collegare un telefono a un modem con SIM per ricevere/effettuare telefonate tramite un apparato telefonico multifrequenza
Foto su Flickr
Annunci





