XAMLator icon indicating copy to clipboard operation
XAMLator copied to clipboard

[Enhancement] Some improvements that may be necessary

Open ChasakisD opened this issue 6 years ago • 3 comments

Hi @ylatuya,

I would like to say that this library is awesome and I would like to say thank you for that.

ControlTemplate

I am using ControlTemplate to some pages and it seems that it cannot find the getter. The stacktrace i've got in the screen is:

Xamarin.Forms.Xaml.XamlParseException: Position 2:635.
Property ControlTemplate is not found or does not have an accessible getter
at
Xamarin.Forms.Xaml.ApplyPropertiesVisitor.GetPropertyValye(System.Object xamlElement, Xamarin.Forms.Xaml.XmlName propertyName, Xamarin.Forms.Xaml.HydrationContext context, System.Xml.IXmlLineInfo lineInfo, System.Object& targetProperty) [0x00095] in D:\a\1\s\Xamarin.Forms.Xaml\ApplyPropertiesVisitor.cs:377
at
Xamarin.Forms.Xaml.ApplyPropertiesVisitor.TryAddToProperty (it got cut here)

DesignInstance

Furthermore, I am using Jetbrains Rider in order to get some Xaml Intellisense improvements and while I am setting the BindingContext at runtime(through a ViewModelLocator) i use

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DataContext="{d:DesignInstance typeHere}"
mc:Ignorable="d"

and i get this stacktrace on screen:

Xamarin.Forms.Xaml.XamlParseException: Position 2:774.
MarkupExtension not found for d:DesignIntance
at
Xamarin.Forms.Xaml.ExpandMarkupsVisitor+MarkupExpansionParser.Parse(System.String match, System.String& remaining, System.IServiceProvider serviceProvider) [0x000e4] in D:\a\1\s\Xamarin.Forms.Xaml\ExpandMarkupsVisitor.cs:144
at
Xamarin.Forms.Xaml.ExpandMarkupsVisitor.ParseExpression(System.String& expression, System.Xml.IXmlNamespaceResolver nsResolver, System.Xml.IXmlLineInfo (it got cut here)

FYI, i've got this binding warning with LogWarningsToApplicationOutput = true;

Binding: 'CloseCommand' property not found on 'XAMLator.Server.ErrorViewModel', target property: 'Xamarin.Forms.Button.Command'

I will take a look at the code and may contribute fixing those issues.

Last but not least, I have never worked with VS Extension Development but I would like to start and help to develop the XAMLator VS 2017 Extension, just to make the Xamarin Development much easier 🙂

Thanks again for all your effort

ChasakisD avatar Nov 05 '18 09:11 ChasakisD

Hi! Thanks for your feedback! I believe the CloseCommand error would be the easier one to fix. The ErrorViewModel is missing that command property and it should be set before the preview, here: https://github.com/ylatuya/XAMLator/blob/master/XAMLator.Server.Shared/Previewer.cs#L62 Using the command created here: https://github.com/ylatuya/XAMLator/blob/master/XAMLator.Server.Shared/Previewer.cs#L25

For the DesingInstance instance we might need to register that extension somehow but I don't know how to do it honestly.

For the ControlTemplate issue, it's probably because pages are previewed with the PreviewPage class, which might not be supporting it, we should find a way to support it correctly.

ylatuya avatar Nov 05 '18 10:11 ylatuya

I will look to the binding warning, as far as I've got some free time.

During some research, ControlTemplate appears on the TemplatedPage which inherits from Page, while the PreviewPage is MultiPage< Page > and not MultiPage< TemplatedPage >

ChasakisD avatar Nov 05 '18 10:11 ChasakisD

A solution would be to add the bindable property to the PreviewPage and forward it to the child page

ylatuya avatar Nov 05 '18 13:11 ylatuya