Visualizzazione post con etichetta Windows phone 8. Mostra tutti i post
Visualizzazione post con etichetta Windows phone 8. Mostra tutti i post

venerdì 14 marzo 2014

Windows Phone 8 Development Succinctly - Free ebook


I'm so glad to announce the new free ebook from Syncfusion:

Windows Phone 8 Development Succinctly

This ebook is written by my friend Matteo Pagani and you can download 243 pages in PDF or Kindle format.

Before starting, please remember: if you are a beginner in development, this ebook is not for you. You need to know the basic concepts of the C# programming.

This book covers all the features of Windows Phone so it's also a good read if you are new in wp development.

Main chapters:

  1. Introduction: 
  2. The User Interface: Basic XAML Concepts
  3. Core Concepts
  4. Data Access: Storage
  5. Data Access: Network
  6. Integrating with the Hardware
  7. Integrating with the Operating System
  8. Multimedia Applications
  9. Live Apps: Tiles, Notifications, and Multitasking
  10. Distributing the Application: Localization, the Windows Phone Store, and In-App Purchases

Pro
  • free! :)
  • easy and fast to read
  • all development cycle
  • a lot of samples and tips
  • Kindle format
  • finally an ebook that explains all storage approaches

Meanwhile you can download the Syncfusion wp controls (now at special price) to make more fast your development. Hurry up! ;)


domenica 2 marzo 2014

Windows Phone 8 - WriteableBitmap and app resume


When I upgraded my WP7 projects to Windows Phone 8, I discovered a strange behavior.

I usually update the tiles in the Application_Deactivated and Application_Closing event, but in wp8 the app crashes while it resumes.
The tiles were created in the storage, so all works good.

The problem seems related to the WriteableBitmap.Render method. I don't know why it blocks the UI thread!

If you have the same behavior, you can use a workaround:

In the App.xaml.cs add the Navigating event in the InitializePhoneApplication method
RootFrame.Navigating += RootFrame_Navigating;

Use the app://external/ string to know when you are exiting from the application
void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e)
{
 if(e.Uri.OriginalString=="app://external/")
 {
  // update my custom tiles
 }
}

sabato 4 gennaio 2014

Windows Phone 8 - Folders and files


Windows Phone 8 introduced the ApplicationData class to easily work with IsolatedStorage and async/await keywords.

In Windows Phone currently it is possible to use only LocalFolder because RoamingStorage and TemporaryStorage throw the NotSupportedException.

However, all the operations can be done with a few lines.

How to use folders

Create folder

StorageFolder folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("myFolder", CreationCollisionOption.ReplaceExisting);


Read folder

var folder = await ApplicationData.Current.LocalFolder.GetFolderAsync("myFolder");


Check if folder exists

StorageFolder folder;
try
{
    folder = await ApplicationData.Current.LocalFolder.GetFolderAsync("myFolder");
    MessageBox.Show(folder.Name);
}
catch (FileNotFoundException ex)
{
    MessageBox.Show("Folder not found");
}


Read all folders

var folders = await ApplicationData.Current.LocalFolder.GetFoldersAsync();
foreach (var folder in folders)
    MessageBox.Show(folder.Name);


Rename folder

var folder = await ApplicationData.Current.LocalFolder.GetFolderAsync("myFolder");
await folder.RenameAsync("myRenamedFolder");


Delete folder

var folder = await ApplicationData.Current.LocalFolder.GetFolderAsync("myFolder");
await folder.DeleteAsync(StorageDeleteOption.PermanentDelete);


How to use files

Create file

var file = await ApplicationData.Current.LocalFolder.CreateFileAsync("myFile.txt", CreationCollisionOption.ReplaceExisting);


Read all files

var files = await ApplicationData.Current.LocalFolder.GetFilesAsync();
foreach (var file in files)
    MessageBox.Show(file.Name);


Check if file exists

StorageFile file;
try
{
    file = await ApplicationData.Current.LocalFolder.GetFileAsync("myFile.txt");
    MessageBox.Show(file.Name);
}
catch (FileNotFoundException ex)
{
    MessageBox.Show("file not found");
}

Write file

var file = await ApplicationData.Current.LocalFolder.CreateFileAsync("myFile.txt", CreationCollisionOption.ReplaceExisting);
var stream = await file.OpenAsync(FileAccessMode.ReadWrite);
using (var writer = new DataWriter(stream.GetOutputStreamAt(0)))
{
    writer.WriteString("Hello");
    await writer.StoreAsync();
    await writer.FlushAsync();
}


Read file

var file = await ApplicationData.Current.LocalFolder.GetFileAsync("myFile.txt");
var stream = await file.OpenAsync(FileAccessMode.Read);
 
using (var reader = new DataReader(stream.GetInputStreamAt(0)))
{
    var bytes = await reader.LoadAsync((uint)stream.Size);
    var s = reader.ReadString(bytes);
    MessageBox.Show(s);
}


Rename file

var file = await ApplicationData.Current.LocalFolder.GetFileAsync("myFile.txt");
await file.RenameAsync("myFileRenamed.txt");


Delete file

var file = await ApplicationData.Current.LocalFolder.GetFileAsync("myFile.txt");
await file.DeleteAsync(StorageDeleteOption.PermanentDelete);


Copy file

var file = await ApplicationData.Current.LocalFolder.GetFileAsync("myFile.txt");
var folder = await ApplicationData.Current.LocalFolder.GetFolderAsync("myFolder");
await file.CopyAsync(folder);


Move file

var file = await ApplicationData.Current.LocalFolder.GetFileAsync("myFile.txt");
var folder = await ApplicationData.Current.LocalFolder.GetFolderAsync("myFolder");
await file.MoveAsync(folder);

The sample project

You can download the sample project here.


The original post is in the Microsoft TechNet Wiki

martedì 12 novembre 2013

Syncfusion TileView - Windows Phone


I found a nice Windows Phone control in the Syncfusion suite: the TileView.
That control has the ability to show a collection of items but one can be maximized to display more informations.





The code is very simple, so let's start to explain the wp8 version!

First of all you need to reference two dll in your project:
  1.  Syncfusion.SfTileView.WP8.dll
  2.  Syncfusion.SfShared.WP8.dll
In the xaml, add the namespace:
xmlns:syncTileView="clr-namespace:Syncfusion.WP.Controls.Layout;assembly=Syncfusion.SfTileView.WP8"

and your TileView object:
<syncTileView:SfTileView ItemsSource="{Binding ComingSoonFilms}" MinimizedItemsOrientation="Right">
   ....
   ....
   ....
</syncTileView:SfTileView>
"MinimizedItemsOrientation property change the orientation of items while the maximized item is displayed"

Now you need the ItemTemplate to show your items and a MaximizedItemTemplate to show the detail.
You can create a simple ItemTemplate with an image:
<syncTileView:SfTileView.ItemTemplate>
 <DataTemplate>
  <Image Source="{Binding Picture}" Width="100" Height="160" Stretch="Fill"/>
 </DataTemplate>
</syncTileView:SfTileView.ItemTemplate>

and a MaximizedItemTemplate like this:
<syncTileView:SfTileView.MaximizedItemTemplate>
 <DataTemplate>
  <Grid>
   <Grid.RowDefinitions>
    <RowDefinition Height="auto"/>
    <RowDefinition/>
   </Grid.RowDefinitions>
   <TextBlock Text="{Binding Title}" Style="{StaticResource PhoneTextLargeStyle}"/>
   <Image Grid.Row="1" Source="{Binding Picture}" Stretch="UniformToFill"/>
  </Grid>
 </DataTemplate>
</syncTileView:SfTileView.MaximizedItemTemplate>

venerdì 13 settembre 2013

Force binding update for a TextBox


The TextBox control updates the Text binding source only when it looses focus.

When you are writing in a TextBox and you press a button in the ApplicationBar, the focus not changes and your MVVM property doesn't update.

The workaround is to force the binding update like this:
 
var focusedElement = FocusManager.GetFocusedElement();
var focusedTextBox = focusedElement as TextBox;

if (focusedTextBox != null)
{
    var binding = focusedTextBox.GetBindingExpression(TextBox.TextProperty);
    if (binding != null)
        binding.UpdateSource();
}


sabato 7 settembre 2013

Install Nokia Pro Camera with Amber


If you can't download Nokia Pro Camera like me...


Here an easy workaround:
  1. Change your phone region and language to United States
  2. Connect to a WiFi network
  3. Under Settings - WiFi, click on the WiFi network you are connected to
  4. Switch 'Proxy' to on. Now type "117.135.139.179" into "Server/URL". In "Port", type in "8888"
  5. Go to the Store and click on 'Nokia Collection'
  6. Download Nokia Pro Cam
  7. When the download started, turn Proxy off
  8. Set your phone region back to normal, and Restart.

domenica 16 giugno 2013

Coding4Fun - ThemedImageConverter

When you publish an application, you need to meet the requirement 5.5.2 from Dev Center:
"App content, such as text and visual elements, must be visible and legible regardless of the phone theme without panning horizontally or zooming.."

The example is when you have an image with the same color of background theme.
What you can do?
- select a different color for image.
- manage the image source swap from code behind.
- the best practice is to use the ThemedImageConverter from Coding4Fun Toolkit.

Let's go:
Download the Coding4Fun Toolkit from NuGet or Codeplex.

Add the static resource in your page:
<c4fun:themedimageconverter x:key="ThemedImageConverter"></c4fun:themedimageconverter>

Use this simple converter in your image:
<Image Source="{Binding Converter={StaticResource ThemedImageConverter}, ConverterParameter={StaticResource PhoneBackgroundColor}}" DataContext="/Assets/{0}/img.png" />

You can check also the InverseThemedImageConverter to swap from light and dark themes.


domenica 21 aprile 2013

Windows Phone 7.8 - Gmail Sync: contacts and calendar

After January 30 2013, Google dropped Exchange ActiveSync support.
Now if you add a Google account in Windows Phone 7.8, you can sync only emails.
But if I want to sync my Google Contacts and Calendars...??

Just follow this steps:
- Go in Settings >>> Email + Accounts.
- Add an account.
- Choose Outlook (Outlook.com, Exchange, Office 365).
- Write you Google email, password and press Sign In button.

Fill the new page with this informations:
- Account: your Google email
- Domain: google
- Server: m.google.com

Et voilà, you done! :)



martedì 19 febbraio 2013

PeriodicTask bug in Windows Phone 8


After almost two months, WPDev Team has confirmed a bug for PeriodicTask in Windows Phone 8:

PeriodicTask fails to trigger if there is no network connectivity in WP8 (enable Airplane mode,  or disable both cellular and wifi.

Here my discussion: http://social.msdn.microsoft.com/Forums/en-US/wpdevelop/thread/216a9f3d-9284-4d1e-ac2a-83f2d13e361c