Tips & Tricks
by DiAbLoxx83
In this post I will show how to create a simple function for ask confirm on exit application.
Step 1. You need to create a function for clear navigation history:
private void ClearBackEntries()
{
while (NavigationService.BackStack != null & NavigationService.BackStack.Count() > 0)
NavigationService.RemoveBackEntry();
}
NOTE: in Markeplace there are many applications with an annoying problem when you try exit from main page: you have to navigate all visited pages. With this function you can solve the problem.
...
When submitting one of my Apps (Number Converter for Windows Phone) to the Windows Phone Marketplace, I got this error when uploading my .XAP file
The [NeutralResourceLanguage] attribute is missing on the entry assembly.
When searched for this error in Google, I found out that the cause of the error is the wrong NeutralResourceLanguage set in the Windows Phone Project.
...
by KHK
It looks like the off-the-shelf WP7 SDK, the Silverlight SDK, and even the Coding4Fun suite lack one very basic piece of functionality that you may want to provide your WP7 app users with: selecting the font style (family, bold, italic), color and size.
Since I needed something like that myself, I thought: why won't I just pack it and share with the fellow developers? ;-)
So, here it is: http://wp7textstylepicker.codeplex.com/
...
by WindowsPhoneGeek
This is the 7th post from the "Windows Phone Application Development for Beginners" series of articles in which I use a more informal approach in order to explain everything you need to know in order to get started developing Windows Phone applications in a simple and easy to understand way.
- Windows Phone App Development for Beginners #1: Intro
- Windows Phone App Development for Beginners #2 Installing the Tools
- Windows Phone App Development for Beginners #3 Getting Help
- Windows Phone App Development for Beginners #4 First Visual Studio project
- Windows Phone App Development for Beginners #5 Basic XAML
- Windows Phone App Development for Beginners #6 Layout
- Windows Phone App Development for Beginners #7 TextBlock control
NOTE: If you are a professional Windows Phone Developer you should probably stop reading now - this series is for absolute beginners.
In short to create Windows Phone application User Interface in addition to layout panels you use controls as well, such as buttons,checkboxes, shapes, text, and other content presented on the screen. Every Control element is reusable and can be customized by setting different value to its properties (For reference take a look at Windows Phone App Development for Beginners #5 Basic XAML ).
...
by Kate Brown
In this quick tip I will demonstrate how easy it is to implement Twitter and Facebook sharing when developing for Windows Phone. In fact many people think that it is hard and time consuming implementation but there is a pretty fast and simple alternative using the new aditional launchers that came with Windows Phone Mango.
So the easiest way to add Twitter and Facebook share buttons is to use the ShareLinkTask class. This class allows your Windows Phone application to launch a dialog that enables the user to share a link on the social networks (of their choice). All you need to do is to use the following code:
ShareLinkTask shareLinkTask = new ShareLinkTask();
shareLinkTask.Title = "Article Title";
shareLinkTask.LinkUri = new Uri("http://www.microsoft.com", UriKind.Absolute);
shareLinkTask.Message = "Some Message to be shared";
shareLinkTask.Show();
As it is written in the MSDN documentation:
LinkUri: Gets or sets the link URI that will be displayed in the link sharing dialog.
Message: Gets or sets the message that will accompany the link when it is shared.
Title: Gets or sets the title of the link to be shared.
NOTE: You will also have to include the following namespace using Microsoft.Phone.Tasks;
...
by Waleed Arafa Al-Zoghby
In this article I'm going to talk about "Data Binding" between elements. I will use "Slider" & "TextBox" elements to clarify the idea.
Suppose that you have 2 elements a slider and a TextBox; and you want to bind the value of slider to the text property of textbox element so you will have a binding source: "Slider" and Binding target: "TextBox" .... it's easy....! Add an event handler "ValueChanged" of slider element and write one line of code like ' TextBox1.Text = Slider1.Value.ToString(); '... it's a traditional method to bind! But I want to demonstrate a feature supported by Silverlight for Windows Phone without adding an event handler.
We will create a new Windows Phone application and drag & drop a slider and TextBox elements on the current page like on the screenshot below. Next, select the TextBox and then "Apply Data Binding." from the Properties Window:
...
by WindowsPhoneGeek
This is the 6th post from the "Windows Phone Application Development for Beginners" series of articles in which I use a more informal approach in order to explain everything you need to know in order to get started developing Windows Phone applications in a simple and easy to understand way.
- Windows Phone App Development for Beginners #1: Intro
- Windows Phone App Development for Beginners #2 Installing the Tools
- Windows Phone App Development for Beginners #3 Getting Help
- Windows Phone App Development for Beginners #4 First Visual Studio project
- Windows Phone App Development for Beginners #5 Basic XAML
- Windows Phone App Development for Beginners #6 Layout
NOTE: If you are a professional Windows Phone Developer you should probably stop reading now - this series is for absolute beginners.
In short you use different Panels to define the layout of your Windows Phone application. The term layout describes the process of sizing and positioning objects in your app. To position UI elements such as buttons,checkboxes, shapes, text, and other content presented on the screen, you must put them in a Panel (or other container object).
NOTE: I will start using the terms "UI element" or "Object" in order to describe elements such as buttons,checkboxes, shapes, text, and other content presented on the screen.
To allow for complex layouts, Silverlight for Windows Phone currently implements panel elements such as Canvas, StackPanel, and Grid discussed below.
...
by WindowsPhoneGeek
In this quick tip I am going to talk about how to add TiltEffect to the MultilistSelect control(which is part from the Windows Phone Toolkit).
For more information of how to get started using MultiselectList control take a look at:
- Windows Phone Toolkit MultiselectList in depth | Part1: key concepts and API
- Windows Phone Toolkit MultiselectList in depth| Part2: Data Binding
I will also use the source code from this previously posted article: How to get the Tapped Item in a MultiselectList control
How to add Tilt Effect to MultiselectList?
Usually, the only thing that you have to do in order to use the TiltEffect is to set toolkit:TiltEffect.IsTiltEnabled="True" like in the snippet bellow:
...
As you already know, a pirated xap of your app was probably uploaded to p2p networks after 1 day from publication, and is now illegally used by lots of people.
In the meantime MS will introduce the server-side-encryption (hopefully soon), hacking a xap is so simple that it is done by automated web applications.
Anyway, you can now turn piracy to your advantage! With this code, you can detect if your app was hacked using the "automated" method, and if so just open the Marketplace pointing to your "real" app.
Basically, an hacked xap is identical as your original xap, lacking a file called WMAppPRHeader.xml (the DRM file), so the phone considers it as a homebrew one and runs it as "full" on unlocked devices.
Just add this code when your app starts and you will be safe for 99.99% of times (this will not protect against reverse engineering and dedicated app attack, but if this happens your app will be famous !). It is a good idea to obfuscate the code too, but first of all implements this trick!
...
by Tianyu Zhang
While developing my latest WP7 app I came across the question how to add a Panorama to my existing WP7 project. I did not want to use the default Visual Studio templates because they generate too much code(for a simple app like mine) with all the data binding and view models.
In short I had a database and wanted to show some data in a Panorama control without using MVVM or any default VisualStudio template. So here is what I did:
Step1. Lets say that we have an existing Windows Phone application project.
Step2. Add a reference to "Microsoft.Phone.Controls" available under the .NET tab in the "Add Reference" window:
...
Our Top Articles & Free books
- Our FREE e-book: "Windows Phone Toolkit In Depth" 2nd edition
- 400+ Windows Phone Development articles in our Article Index
- 21 WP7 Toolkit in Depth articles covering all controls
- 12 WP7 Coding4Fun Toolkit in Depth articles covering all controls
- Performance Tips when creating WP7 apps
- Creating a WP7 Custom Control in 7 Steps
- WP7 working with VisualStates: How to make a ToggleSwitch from CheckBox
- What makes a WP7 App successful
- Creating theme friendly UI in WP7 using OpacityMask
- Implementing Windows Phone 7 DataTemplateSelector and CustomDataTemplateSelector
- All about Splash Screens in WP7 – Creating animated Splash Screen
- Getting Started with Unit Testing in Silverlight for WP7
- WP7 WatermarkedTextBox custom control
Our Top Tips & Samples
- All about WP7 Isolated Storage series
- WP7 Dynamically Generating DataTemplate in code
- 5 tips for a successful WP7 Marketplace submission
- WP7: Navigating to a page in different assembly
- WP7 ContextMenu: answers to popular questions
- WP7 ListBox: answers to popular questions
- WP7 working with Images: Content vs Resource build action
- WP7 Element Binding samples
- WP7 working with XML: reading, filtering and databinding
- Drawing in WP7: #2 Drawing shapes with finger
- WP7 TextBox Light theme problems - the solution
- Changing the WP7 Panorama Background Image dynamically with Animation
