Giter Club home page Giter Club logo

Comments (15)

github-actions avatar github-actions commented on June 21, 2024 1

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

from maui.

rogerbriggen avatar rogerbriggen commented on June 21, 2024

The same error if you use
SelectionChangedCommandParameter="{Binding Source={RelativeSource Self}, Path=SelectedItem}"

from maui.

kevinxufei avatar kevinxufei commented on June 21, 2024

Verified this issue with Visual Studio 17.10 Preview 7.0 + NET9.0 SDK (9.0.100-preview.3.24204.13).
MauiVersion = 9.0.0-preview.3.10457, repro this issue;
MauiVersion = 9.0.0-preview.2.10293, works well.

from maui.

cgp1976 avatar cgp1976 commented on June 21, 2024

Hi guys, I am facing these issues as well. Is there any workaround settings where we can bypass the error from XamlC

similar to
<XFDisableTargetsValidation>True</XFDisableTargetsValidation>

cos right now, I can't build and compile the project. kindly advise.

from maui.

drasticactions avatar drasticactions commented on June 21, 2024

public static BuildExceptionCode BindingPropertyNotFound = new BuildExceptionCode("XFC", 0045, nameof(BindingPropertyNotFound), "");

<Item ItemId=";BindingPropertyNotFound" ItemType="0;.resx" PsrId="211" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Binding: Property "{0}" not found on "{1}".]]></Val>
</Str>
<Disp Icon="Str" />
<Cmts>
<Cmt Name="Dev"><![CDATA[0 is property name, 1 is type name]]></Cmt>
</Cmts>
</Item>

There's been a few changes in SetPropertiesVisitor since Preview2, and I think this is the only place that throws that exception: https://github.com/dotnet/maui/blame/main/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs

@simonrozsival Would you have any ideas what it could be?

from maui.

simonrozsival avatar simonrozsival commented on June 21, 2024

@rogerbriggen @drasticactions previously, any binding with Source wasn't compiled. After a recent change (#20610), we can now compile all bindings. Unfortunately, we can't infer the x:DataType form Source yet (#21834) and so in this case, the compiler doesn't know that it shouldn't be looking for the property SelectedItem on MainPageViewModel but instead on CollectionView.

As a fix, you can set the x:DataType on the binding that shouldn't inherit the parent's x:DataType:

<CollectionView 
    x:Name="myCollection" 
    ItemsSource="{Binding Items}" 
    ...
    SelectionChangedCommandParameter="{Binding Source={x:Reference myCollection}, Path=SelectedItem, x:DataType=CollectionView}">
    <CollectionView.ItemTemplate>
     ...
    </CollectionView.ItemTemplate>
</CollectionView>

Does this solve your problem?

from maui.

cgp1976 avatar cgp1976 commented on June 21, 2024

one thing I found out is that when any parent element has assigned the x Attribute x:DataType with value, those child elements will be overriding with the parent value... basically, it is using the parent context to find the binding hence it throws the Property Binding not found.

from maui.

cgp1976 avatar cgp1976 commented on June 21, 2024

@rogerbriggen @drasticactions previously, any binding with Source wasn't compiled. After a recent change (#20610), we can now compile all bindings. Unfortunately, we can't infer the x:DataType form Source yet (#21834) and so in this case, the compiler doesn't know that it shouldn't be looking for the property SelectedItem on MainPageViewModel but instead on CollectionView.

As a fix, you can set the x:DataType on the binding that shouldn't inherit the parent's x:DataType:

<CollectionView 
    x:Name="myCollection" 
    ItemsSource="{Binding Items}" 
    ...
    SelectionChangedCommandParameter="{Binding Source={x:Reference myCollection}, Path=SelectedItem, x:DataType=CollectionView}">
    <CollectionView.ItemTemplate>
     ...
    </CollectionView.ItemTemplate>
</CollectionView>

Does this solve your problem?
Many thanks for the response. Seem like I just need to remove the x:DataType for the time being.

from maui.

drasticactions avatar drasticactions commented on June 21, 2024

@simonrozsival Okay, that makes sense. Should this issue be closed then and duplicated under #21834?

from maui.

simonrozsival avatar simonrozsival commented on June 21, 2024

@drasticactions I'm not sure. I think this is mostly a documentation issue. We've made changes to how XamlC compiles bindings in .NET 9, but we haven't updated the docs yet. I think we need a new issue that will track the necessary changes to documentation and then we can close this issue.

from maui.

rogerbriggen avatar rogerbriggen commented on June 21, 2024

@rogerbriggen @drasticactions previously, any binding with Source wasn't compiled. After a recent change (#20610), we can now compile all bindings. Unfortunately, we can't infer the x:DataType form Source yet (#21834) and so in this case, the compiler doesn't know that it shouldn't be looking for the property SelectedItem on MainPageViewModel but instead on CollectionView.

As a fix, you can set the x:DataType on the binding that shouldn't inherit the parent's x:DataType:

<CollectionView 
    x:Name="myCollection" 
    ItemsSource="{Binding Items}" 
    ...
    SelectionChangedCommandParameter="{Binding Source={x:Reference myCollection}, Path=SelectedItem, x:DataType=CollectionView}">
    <CollectionView.ItemTemplate>
     ...
    </CollectionView.ItemTemplate>
</CollectionView>

Does this solve your problem?

@cgp1976 Yes, this solves this issue. The only thing which is, that Visual Studio shows an error
image
The text means "the datatype property was not found in type BindingExtension.
Do I need to create a bug for that? Where?

from maui.

simonrozsival avatar simonrozsival commented on June 21, 2024

@rogerbriggen I think this is the same warning we saw in #21434. This seems to be a bug in the XAML editor in VS. I wonder where the best place to report it is (cc @StephaneDelcroix @PureWeen).

from maui.

drasticactions avatar drasticactions commented on June 21, 2024

@mgoertz-msft Would you know?

from maui.

mgoertz-msft avatar mgoertz-msft commented on June 21, 2024

Xamarin and MAUI never cease to surprise me on what they allow that other platforms like WPF and UWP/WinUI don't. I had no idea this was allowed to be used that way.

from maui.

simonrozsival avatar simonrozsival commented on June 21, 2024

I reported the issue in the VS Code extension here: microsoft/vscode-dotnettools#1131

from maui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.