Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Win][AncestralBinding] throws COMException #1218

Closed
Xiaoy312 opened this issue Aug 6, 2024 · 1 comment · Fixed by #1220
Closed

[Win][AncestralBinding] throws COMException #1218

Xiaoy312 opened this issue Aug 6, 2024 · 1 comment · Fixed by #1220
Assignees
Labels
control/extensions-helpers-markup Related to attached properties, helper classes, or markup extensions without a finer tag kind/bug Something isn't working

Comments

@Xiaoy312
Copy link
Contributor

Xiaoy312 commented Aug 6, 2024

Current behavior

<ListView ItemsSource="{Binding Files, Mode=OneWay}">
	<ListView.ItemTemplate>
		<DataTemplate>
			<Button IsEnabled="{utu:AncestorBinding AncestorType=ListView, Path=DataContext.IsBusy}" />
throws COMException
System.Runtime.InteropServices.COMException (0x80004005)
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|39_0(Int32 hr)
   at WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr)
   at ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.MeasureOverride(IObjectReference _obj, Size availableSize)
   at Microsoft.UI.Xaml.FrameworkElement.MeasureOverride(Size availableSize)
   at Microsoft.UI.Xaml.FrameworkElement.Microsoft.UI.Xaml.IFrameworkElementOverrides.MeasureOverride(Size availableSize)
   at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_MeasureOverride_0(IntPtr thisPtr, Size availableSize, Size* result)

---OR---

<Page ...>
	<Button IsEnabled="{utu:AncestorBinding AncestorType=Page, Path=DataContext.IsBusy}" />
throws XamlParseException
Microsoft.UI.Xaml.Markup.XamlParseException: 'The text associated with this error code could not be found.

Failed to assign to property 'Microsoft.UI.Xaml.Controls.Control.IsEnabled' because the type 'Windows.Foundation.Object' cannot be assigned to the type 'Windows.Foundation.Boolean'. [Line: 14 Position: 11]'

throws exception.

Expected behavior

^ should not throw any exception.

How to reproduce it (as minimally and precisely as possible)

Nuget Package: Uno.Toolkit.WinUI@6.0.18
Affected platform(s): Windows

@Xiaoy312 Xiaoy312 added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification. control/extensions-helpers-markup Related to attached properties, helper classes, or markup extensions without a finer tag and removed triage/untriaged Indicates an issue requires triaging or verification. labels Aug 6, 2024
@Xiaoy312
Copy link
Contributor Author

Xiaoy312 commented Aug 6, 2024

In AncestorBinding::ProvideValue, we are first returning a default null value when the binding isnt ready to happen. For some dependency property, it would be illegal.
Given that we must return something by interface's contract, we should probably return the default value for the target property, or better yet the current value on this property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
control/extensions-helpers-markup Related to attached properties, helper classes, or markup extensions without a finer tag kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant