Skip to content

Allow Style.BasedOn to be set to {x:Null} #2470

Closed

Description

@paulovila

Current behavior

if I declare a style as

 <Style x:Key="MaterialDesignRaisedButton" TargetType="Button" BasedOn="{x:Null}">

the solution fails to compile because it generates this code:

 public static global::Windows.UI.Xaml.Style MaterialDesignRaisedButton
        {
            get
            {
                if(!_MaterialDesignRaisedButtonInitialized)
                {
                    __MaterialDesignRaisedButtonBackingField = 
                        new global::Windows.UI.Xaml.Style(typeof(global::Windows.UI.Xaml.Controls.Button))
                        {
                            BasedOn = (global::Windows.UI.Xaml.Style)#Error // NullExtension could not be found.,
                            Setters = 
                            {
                            }
                        }
                        ;
                    _MaterialDesignRaisedButtonInitialized = true;
                }
                return __MaterialDesignRaisedButtonBackingField;
            }
        }

Expected behavior

I'm not sure if setting BasedOn to null is equivalent to not generate the setting code at all. What I'm sure is that it should compile.

Environment

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Windows
  • Build tasks
  • Solution Templates

Activity

  1. added
    kind/bug
    triage/untriaged
    on Jan 13, 2020
  2. removed
    triage/untriaged
    on Jan 14, 2020
  3. jeromelaban commented on Jan 14, 2020

    @jeromelaban
    Member

    /cc @davidjohnoliver this should be adressed as part of the Styles work #119 and #1766

  4. added
    project/styling 👔
    on Jul 2, 2020
  5. modified the milestone: 3.1 on Aug 29, 2020
  6. added
    hacktoberfest
    help wanted
    on Sep 25, 2020
  7. davidjohnoliver commented on Sep 25, 2020

    @davidjohnoliver
    Contributor

    Guidance for contributors: this one will involve making modifications to the XamlFileGenerator class. You can enable debugging and source-method annotation in the XamlCodeGeneration class.

    Don't forget to add a unit test in Uno.UI.Tests. :)

  8. kazo0 commented on Oct 2, 2020

    @kazo0
    Contributor

    Is this issue still a thing now that the Styles work that Jerome mentioned is done?

  9. davidjohnoliver commented on Oct 5, 2020

    @davidjohnoliver
    Contributor

    @kazo0 It's probably still happening, it most likely requires a special case for the Xaml generation that was left out of the Styles work. But test it out in a blank app and see, maybe it works :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    hacktoberfesthelp wantedkind/bugproject/styling 👔

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions