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

MarkupExtension.ProvideValue doesnt have the proper target injected when used on attached property #14749

Closed
Xiaoy312 opened this issue Dec 7, 2023 · 0 comments · Fixed by #14750
Assignees
Labels
area/code-generation Categorizes an issue or PR as relevant to code generation difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers kind/bug Something isn't working project/core-tools 🛠️ Categorizes an issue or PR as relevant to core and tools

Comments

@Xiaoy312
Copy link
Contributor

Xiaoy312 commented Dec 7, 2023

Current behavior

public partial class ResponsiveExtension : MarkupExtension {
	protected override object? ProvideValue(IXamlServiceProvider serviceProvider) {
		var pvt = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget;
		var target = pvt.TargetObject; // null
<Border Grid.Column="{utu:Responsive Narrowest=0, Narrow=1, Normal=0, Wide=1, Widest=1}" />

Expected behavior

^ should just work.

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

See "##Current behavior"

Workaround

n/a

Works on UWP/WinUI

Yes

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

Uno.WinUI@5.1.0-dev.486

Affected platforms

Build tasks

IDE

Visual Studio 2022

IDE version

n/a

Relevant plugins

n/a

Anything else we need to know?

// <Border Grid.Column="{utu:Responsive Narrowest=0, Narrow=1, Normal=0, Wide=1, Widest=1}" />
global::Microsoft.UI.Xaml.Controls.Grid.SetColumn(c11, (int)Microsoft.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(
	typeof(int), 
	((global::Microsoft.UI.Xaml.Markup.IMarkupExtensionOverrides)new global::Uno.Toolkit.UI.ResponsiveExtension { Narrowest = @"0", Narrow = @"1", Normal = @"0", Wide = @"1", Widest = @"1" })
		.ProvideValue(global::Uno.UI.Helpers.MarkupHelper.CreateParserContext(
			null, // <============================= null here
			typeof(global::Microsoft.UI.Xaml.Controls.Grid), 
			"Column", 
			typeof(object)))));

// for comparison
// <StackPanel Orientation="{utu:Responsive Normal=Vertical, Wide=Horizontal}" />
c8.Orientation = (global::Microsoft.UI.Xaml.Controls.Orientation)Microsoft.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(
	typeof(global::Microsoft.UI.Xaml.Controls.Orientation), 
	((global::Microsoft.UI.Xaml.Markup.IMarkupExtensionOverrides)new global::Uno.Toolkit.UI.ResponsiveExtension { Normal = @"Vertical", Wide = @"Horizontal" })
		.ProvideValue(global::Uno.UI.Helpers.MarkupHelper.CreateParserContext(
			c8, 
			typeof(global::Microsoft.UI.Xaml.Controls.StackPanel), 
			"Orientation", 
			typeof(object))));
@Xiaoy312 Xiaoy312 added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. area/code-generation Categorizes an issue or PR as relevant to code generation project/core-tools 🛠️ Categorizes an issue or PR as relevant to core and tools and removed triage/untriaged Indicates an issue requires triaging or verification labels Dec 7, 2023
@Xiaoy312 Xiaoy312 self-assigned this Dec 7, 2023
@MartinZikmund MartinZikmund added difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers and removed difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/code-generation Categorizes an issue or PR as relevant to code generation difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers kind/bug Something isn't working project/core-tools 🛠️ Categorizes an issue or PR as relevant to core and tools
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants