Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Embedding a custom Content View in another xaml - Exception: System.InvalidCastException: Specified

$
0
0

Hi,
I've created my own C# content view class with XAML using the "Add Item" menu option in Visual Studio.

I try to embed this content view into a the xaml of a Page class and at runtime the InitializeComponent() method in my ContentView's View.g.cs file throws
and exception "Exception: System.InvalidCastException: Specified" on the following line of code:

    private void InitializeComponent() {
        global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(TextFieldViewV1));          <<---- THIS THROWS EXCEPTION
        xxamFieldValueEntry = global::Xamarin.Forms.NameScopeExtensions.FindByName<global::Xamarin.Forms.Entry>(this, "xxamFieldValueEntry");
    }

The XAML for my Content View "TextFieldViewV1" is trivial:


<ContentView.Content>



</ContentView.Content>

I include the namespace of the content view in the Xaml of my test page and the project compiles without errors.


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>