Im trying to create my own(custom design) popup for my WP7 application. To put it shortly it should only display bing map with a drawn route and a close button.
I have used the Picker Box by from Alex Yakhnin's Blog. And by his code as a reference i have made my custom xaml file with the following (only basic design, maps and button left behind for now to make this post a bit shorter).
<ResourceDictionary xmlns:my="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Skanetrafiken.Controls;assembly=Skanetrafiken.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
>
<Style TargetType="local:MapRouteDialog">
<Setter Property="Background" Value="{StaticResource PhoneChromeBrush}"/>
<Setter Property="Width" Value="480"/>
<Setter Property="Height" Value="800"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:MapRouteDialog"></ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
I have this is my own assembly where both namespace and assembly is "Skanetrafiken.Controls", and here i also got my class named "MapRouteDialog" (inherits from ContentControl).
In my class i have pretty much a copy of the following from Alex picker example.
internal Popup ChildWindowPopup { get; private set; }
private static PhoneApplicationFrame RootVisual
{
get
{
return Application.Current == null ? null : Application.Current.RootVisual as PhoneApplicationFrame;
}
}
public void Show()
{
if (this.ChildWindowPopup == null)
{
this.ChildWindowPopup = new Popup();
try
{
this.ChildWindowPopup.Child = this;
}
catch (ArgumentException)
{
throw new InvalidOperationException("This control is already shown.");
}
}
if (this.ChildWindowPopup != null && Application.Current.RootVisual != null)
{
this.ChildWindowPopup.IsOpen = true;
}
if (RootVisual != null)
{
// Hook up into the back key press event of the current page
((PhoneApplicationPage)RootVisual.Content).BackKeyPress += new EventHandler<System.ComponentModel.CancelEventArgs>(MapRouteDialog_BackKeyPress);
}
}
My real problem is that when my method Show() runs, everything runs and nothing crashes but no popup, my normal WP7 page is still visible. I can't figure out whats wrong and right now i can only think of, maybe the resource can't be found or something but have no idea how to fix it if this is the case.
I also has the OnApplyTemplate overriden and on the contructor i set the DefaultStyleKey = typeof(MapRouteDialog)
.