I know it is a bad idea to put a WebBrowser inside a Pivot/RadSlideView control. I did so anyway:
<phone:PhoneApplicationPage
x:Class="**.HtmlView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
mc:Ignorable="d"
Style="{StaticResource LeafPageNavigationStyle}">
<controls:Pivot x:Name="Html" ItemsSource="{Binding Items}"
Style="{StaticResource HeaderlessPivot}">
<controls:Pivot.ItemTemplate>
<DataTemplate>
<phone:WebBrowser Source="{Binding}" />
</DataTemplate>
</controls:Pivot.ItemTemplate>
</controls:Pivot>
</phone:PhoneApplicationPage>
Basically I want to use the Pivot to slide through an array of HTML docs at URIs I provide via my ViewModel, which just wraps an the array in a Caliburn.Micro OneActive Conductor:
namespace DSBMobile.ViewModels
{
public class HtmlViewModel : Conductor<Uri>.Collection.OneActive
{
private readonly IUnburyableState<Uri[], HtmlViewModel> _state;
public HtmlViewModel(IUnburyableState<Uri[], HtmlViewModel> state)
{
_state = state;
Items.AddRange(_state.State.ForceGetValue());
}
}
}
That runs pretty well in debug and release versions I deploy manually. The App passes all tests imposed by the Store, but as soon as I try to open this specific view within the app, it crashes without any chance to redirect to a Telerik MessageBox.
As soon as I remove the outer Pivot and adjust the ViewModel accordingly, it runs smoothely. As I a said, the crash only happens in production. The Application.UnhandledException handler can't get the app to swallow the exception and display the error.
This is really intricate and bugs me since months. Can anyone resolve this error or point me in a worthwhile direction? I would also appreciate a more WP-ish suggestion for displaying multiple Web links that works.
It turns out that I got an UnauthorizedAccessException, explaining that I was missing the ID_CAP_WEBBROWSERCOMPONENT capability, which I wasn't. That confused me, until I finally had a look at the docs:
When you create a WebBrowser control in XAML, you must specify a value for the P:System.Windows.FrameworkElement.Name property for that control so that the Windows Phone Capability Detection Tool can properly detect and grant the right capabilities for your app. For more info about the Windows Phone Capability Detection Tool, see How to determine app capabilities.
With the x:Name set, I could finally have a crashless experience. For me personally, this was the most annoying bug, ever. It helped that I could upload beta versions in the store although I didn't pay any developer fee, which I hadn't known in beforehand.
TLDR: RTFM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With