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

Can't use a binding to a staticresource in a style #4850

Closed
6 of 24 tasks
stefanolson opened this issue Jan 8, 2021 · 1 comment
Closed
6 of 24 tasks

Can't use a binding to a staticresource in a style #4850

stefanolson opened this issue Jan 8, 2021 · 1 comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working project/binding 🪢 Categorizes an issue or PR as relevant to the binding engine

Comments

@stefanolson
Copy link

stefanolson commented Jan 8, 2021

Current behavior

Error: Preprocessor directive expected. Code:

<local:BrandingAccessor x:Key="BrandingAccessor" />
    <Style TargetType="local:CustomControl1">
        <Setter Property="Background" Value="{Binding Source={StaticResource BrandingAccessor}, Path=Branding.InfoButtonBackgroundBrush}"/>

In output .cs file:

Setters = 
					{
						new global::Windows.UI.Xaml.Setter(global::UnoApp.CustomControl1.BackgroundProperty, __ResourceOwner_0, __ResourceOwner_1 => (Windows.UI.Xaml.Media.Brush)
						#Error // Binding could not be found.
						)
						,
					}

Expected behavior

Should compile as it does in UWP.

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

Build enclosed project: UnoApp.zip

You'll see in mainpage.xaml that I can successfully reference the accessor from a staticresource:
<Grid Background="{Binding Source={StaticResource BrandingAccessor}, Path=Branding.InfoButtonBackgroundBrush}">

Just doesn't seem to work when in a style in a resource dictionary

Workaround

None yet.

Environment

Nuget Package:

  • Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia
  • Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
  • Uno.SourceGenerationTasks
  • Uno.UI.RemoteControl / Uno.WinUI.RemoteControl
  • Other:

Nuget Package Version(s):

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Skia
    • WPF
    • GTK (Linux)
    • Tizen
  • Windows
  • Build tasks
  • Solution Templates

IDE:

  • Visual Studio 2017 (version: )
  • Visual Studio 2019 (version: 16.8.3 )
  • Visual Studio for Mac (version: )
  • Rider Windows (version: )
  • Rider macOS (version: )
  • Visual Studio Code (version: )

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

@stefanolson stefanolson added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Jan 8, 2021
@jeromelaban jeromelaban added project/binding 🪢 Categorizes an issue or PR as relevant to the binding engine and removed triage/untriaged Indicates an issue requires triaging or verification labels Jan 8, 2021
@jeromelaban jeromelaban added the difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. label Feb 15, 2021
@MartinZikmund
Copy link
Member

MartinZikmund commented Jun 4, 2021

Duplicate of #4826

@MartinZikmund MartinZikmund marked this as a duplicate of #4850 Jun 4, 2021
@MartinZikmund MartinZikmund marked this as a duplicate of #4826 Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working project/binding 🪢 Categorizes an issue or PR as relevant to the binding engine
Projects
None yet
Development

No branches or pull requests

3 participants