Forum Visual Studio

Xamarin Forms previewer does not preview if I use custom control

JsinhJsinh INUniversity ✭✭

Just installed latest bits of Xamarin Studio v6.1 which supports and provides Xamarin Forms Previewer.

When I open up a XAML file where I have used a simple custom control and it gives me error (does not go away if I clean / rebuild / build)

Reason to post this and ask is because I read this line in updates announcements - "In addition to the standard controls, the Previewer has support for loading and executing custom controls and custom renderers live."

https://blog.xamarin.com/major-updates-ios-10-android-nougat-and-other-tasty-bits/

Attached screenshots for details.

Any one?

Best Answer

Answers

  • JohnDBJohnDB USMember ✭✭
    edited September 2016

    I'm seeing the exact same problem. I found there were 2 issues, both related to my App.xaml file:

    1) I'd missed the ;assembly=[assemblyname] part off the local namespace
    2) I had to change references to resources defined in App.xaml from {StaticResource} to {DynamicResource}.

    The form then rendered.

    The first issue is fair enough, it couldn't resolve the type, but I don't know why the resources must be referenced using {DynamicResource}. That seems odd.

  • JsinhJsinh INUniversity ✭✭

    Hello @JohnDB thanks for the hint, it helps to resolve basic issues for previewer to work.

    Now I am stuck at second level. Previewer is not showing custom control, instead show blank space in that region.
    Eg:
    xmlns:xamControls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"

    Any further hints? Anyone facing similar issues? Callout for help, thanks!

  • JsinhJsinh INUniversity ✭✭

    To add to previous comment. It was my mistake. If I do not have design data available to bind with it will offcourse show blank space instead. After setting up some mock data to consume at design time. I was able to see preview properly.

    Thanks again @JohnDB for the answer.

    I do not see any options to accept your reply as answer. Not sure how to close this thread / question.

Sign In or Register to comment.