timheuer / callisto

A control toolkit for Windows 8 XAML applications. Contains some UI controls to make it easier to create Windows UI style apps for the Windows Store in accordance with Windows UI guidelines.
http://timheuer.com/blog/archive/2012/05/31/introducing-callisto-a-xaml-toolkit-for-metro-apps.aspx
Other
338 stars 108 forks source link

XamlParseException on WebViewExtension.StringSource #52

Closed techSage closed 12 years ago

techSage commented 12 years ago

I am unable to get WebViewExtension binding to work and am getting two exceptions thrown when the binding occurs at runtime. The first thrown exception (chronologically) is: "A System.InvalidCastException was thrown: "Unable to cast object of type 'Windows.UI.Xaml.Data.Binding' to type 'System.String'" and then the XamlParseException.

The InvalidCastException, which seems to be causing the issue is at this line in \obj\Debug\XamlTypeInfo.g.cs: Callisto.WebViewExtension.SetStringSource((Windows.UI.Xaml.Controls.WebView)instance, (System.String)Value);

I have a simple repro app to show this with the following code (full solution available on request). Any ideas how to get this working?

Page:

<Page
    x:Class="WebViewExTestApp.MainPage"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:WebViewExTestApp"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:callisto="using:Callisto"
    mc:Ignorable="d">

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <WebView callisto:WebViewExtension.StringSource="{Binding Content}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
    </Grid>
</Page>

Code:

using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace WebViewExTestApp
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            DataContext = post;
        }

        Post post = new Post() { Content = "This is test content." };

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        public class Post
        {
            public string Content { get; set; }
        }
    }
}