One obvious thing in modern symbian mobiles, is how to detect orientation.
I am currently porting some Silverlight 1.0 samples like GrandPiano to Silverlight for Symbian and I was wondering
how can I detect the phone orientation. Well I just analysed the Bing demo and find out that is kind of simple.
What you need is something like this:
public static readonly DependencyProperty OrientationProperty =
DependencyProperty.Register("Orientation", typeof(Orientation), typeof(Page),
new PropertyMetadata((Orientation)0, new PropertyChangedCallback(OrientationPropertyChanged)));
private static void OrientationPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
(sender as GrandPiano).UpdateOrientation();
}
private void UpdateOrientation()
{
base.Width = (this.Orientation == Orientation.Vertical) ? DeviceVerticalSize.Width : DeviceVerticalSize.Height;
base.Height = (this.Orientation == Orientation.Vertical) ? DeviceVerticalSize.Height : DeviceVerticalSize.Width;
base.Clip = new RectangleGeometry { Rect = new Rect(new Point(), new Size(base.Width, base.Height)) };
}
// Properties
public Orientation Orientation
{
get
{
return (Orientation)base.GetValue(OrientationProperty);
}
set
{
base.SetValue(OrientationProperty, value);
}
}
When I wrote my first application for Silverlight on Symbian, I kept getting this annoying
message I really didnt get why was it.
Finally I downloaded the Bing Xap file and looked at it. And it seams it was just something simple.
<?xml version="1.0" encoding="utf-8"?>
<Deployment
xmlns=http://schemas.microsoft.com/client/2007/deployment
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
ExternalCallersFromCrossDomain="ScriptableOnly"
EntryPointAssembly="BingNokia"
EntryPointType="BingNokia.App"
RuntimeVersion="2.0.31005.0"
>
<Deployment.Parts>
<AssemblyPart x:Name="BingNokia" Source="BingNokia.dll" />
<AssemblyPart x:Name="Microsoft.Windows.Controls.WatermarkedTextBox" Source="Microsoft.Windows.Controls.WatermarkedTextBox.dll" />
<AssemblyPart x:Name="Mvc" Source="Mvc.dll" />
<AssemblyPart x:Name="System.Xml.Linq" Source="System.Xml.Linq.dll" />
</Deployment.Parts>
</Deployment>
My runtime version was wrong.
<Deployment
xmlns=http://schemas.microsoft.com/client/2007/deployment
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
EntryPointAssembly="NokiaTest1"
EntryPointType="NokiaTest1.App"
RuntimeVersion="3.0.40818.0">
<Deployment.Parts>
<AssemblyPart x:Name="NokiaTest1" Source="NokiaTest1.dll" />
</Deployment.Parts>
</Deployment>
I still dont how to customize my AppManifest file
I suppose that behaviour is due to the fact that I have Silverlight 3 installed in my machine.
So what I did is that I compiled my application. Then renamed my .xap for .zip. Extracted my AppManifest.xml and modified it
changing the runtime version and copied it back to my .xap file. And voila!
I am a big fan of mobile applications and recently due to our migration activities
(we now offer migrations from VB6 and WinForms to Silverlight)
have been involved with Silverlight programming.
I have done some mobile application development activities
in J2EE and flash and I am now very happy with Silverlight.
What makes me even happier is that I am a Symbian fan and I can now
start developing applications for my Nokia phone with silverlight.
Dont miss it!: http://www.silverlight.net/getstarted/devices/symbian/