Visually Located


Using a custom UriMapper to navigate to a login screen

When writing a Windows Phone app you might need to prompt the user with login information. Maybe you want to know who in the family is using the app, or the most likely case is that you are trying to make an app that uses web services. When you want to give the user a login screen, you want this to be the first page that they see the first time they open the app. When they have already entered login information you don’t want to show the login screen and instead take them to the main page. There are a few ways to do this. One way that is very common is to place logic into the MainPage.xaml.cs that checks if a login is needed and if so, navigate to the login screen. When doing this you need to take care to remove any backstack entries from the NavigationService when you get to the login page. You do this because if the user hits the back button, you want them to exit the app, not go to your main page. There are two logical places to put the code for this. One in the OnNavigatedTo overr... [More]

Changing the background color of your pivot headers

Let’s say you’re trying to put some style into your app and you really want a nice background color to all of your PivotItem titles. How would you go about doing this? You’re probably thinking “Shawn, that’s easy, just modify the HeaderTemplate on the Pivot.” And I would probably agree with you. Let’s try that out. <controls:Pivot Title="MY APPLICATION"> <controls:Pivot.HeaderTemplate> <DataTemplate> <Grid Background="Red"> <TextBlock Text="{Binding}"/> </Grid> </DataTemplate> </controls:Pivot.HeaderTemplate> <!--Pivot item one--> <controls:PivotItem Header="item1"/>   <!--Pivot item two--> <controls:PivotItem Header="item2"/> </controls:Pivot> Looking at the design view of this gives We ... [More]

Enabling tilt on “non-selectable” items

While working an a recent app I wanted to enable tilt functionality onto a Grid that contained a few items. Unfortunetly I was unable to get the control to tilt. I tried setting all sorts of properties, but nothing worked. I downloaded the source and took a look at it, and the same time I asked the twiiter universe whether non selectable items could be “tiltable” Morten Neilson replied with exactly what I was seeing.  His suggestion was to change the source which is easy enough to do. Just add FrameworkElement to the list. static TiltEffect() { // The tiltable items list. TiltableItems = new List<Type>() { typeof(ButtonBase), typeof(ListBoxItem), typeof(MenuItem), }; } But I wanted to find a way to make this work without having to change the source for the WP7 toolkit. I love open source projects, I have two myself. But it’s a ... [More]

Managing Extents within the ArcGIS WPF/Silverlight/etc. APIs

Managing extents within the ArcGIS .Net client API’s is pretty simple. Esri has an example on the resources page. I implemented one for the ArcFM Silverlight SDK sample. Oddly enough, they are quite similar. I don’t remember copying theirs, but you never know. Like most things we as developers do, after a couple of years you look back and wonder “What was I thinking?” I look back at my original code and wonder why did I implement the Extents class the way that I did. I originally used one List to hold all of the Extents. This made some of the code pretty ugly. I’ve created a different implementation that utilizes two stacks. I have one class that manages all of the extents: 1: public class Extents 2: { 3: private readonly Stack<Envelope> _backStack = new Stack<Envelope>(); 4: private readonly Stack<Envelope> _forwardStack = new Stack<Envelope>(); 5:  6: public bool HasPrevi... [More]

Creating a Custom MessageBox for Windows Phone Applications

UPDATE: See a new post to get the latest code for the custom MessageBox. UPDATE: After posting this blog I found out about the message box within the XNA framework. This does allow for custom button text which is what I was trying to accomplish. However, the user experience is different than what you get from the message boxes within the native phone applications (eg: deleting a text). With the native message boxes, the application bar disappears, but with the XNA message box, it gets greyed out. It’s the little things that matter. Also within the XNA framework you cannot add additional components to the message box. For example, you might want to add a “Do not show me this again” option within the message box. While using a Windows Phone you get prompted every once in awhile by a message box. Custom Applications have them, even apps native to the phone has them. When deleting a text message or a contact you get a nice prompt asking you if you want to delete ... [More]