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

Adding Name to a Resource fails on build #1427

Closed
2 of 9 tasks
NGame1 opened this issue Aug 26, 2019 · 3 comments · Fixed by #1766
Closed
2 of 9 tasks

Adding Name to a Resource fails on build #1427

NGame1 opened this issue Aug 26, 2019 · 3 comments · Fixed by #1766
Labels
area/code-generation Categorizes an issue or PR as relevant to code generation kind/bug Something isn't working project/styling 👔 Categorizes an issue or PR as relevant to element styling

Comments

@NGame1
Copy link

NGame1 commented Aug 26, 2019

Current behavior

this code is fine:

<UserControl.Resources>
    <LinearGradientBrush x:Key="TurnedOnLightGradiantColor" StartPoint="0,0.5" EndPoint="1,0.5">
        <LinearGradientBrush.GradientStops>
            <GradientStop Color="#897de3" Offset="0.5"/>
            <GradientStop Color="#764294" Offset="1"/>
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="TurnedOffLightGradiantColor" StartPoint="0,0.5" EndPoint="1,0.5">
        <LinearGradientBrush.GradientStops>
            <GradientStop Color="LightGray" Offset="0.5"/>
            <GradientStop Color="DarkGray" Offset="1"/>
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
</UserControl.Resources>

but if you add a name it will fail

<UserControl.Resources>
    <LinearGradientBrush x:Name="TurnedOnLightGradiantColorName" x:Key="TurnedOnLightGradiantColor" StartPoint="0,0.5" EndPoint="1,0.5">
        <LinearGradientBrush.GradientStops>
            <GradientStop Color="#897de3" Offset="0.5"/>
            <GradientStop Color="#764294" Offset="1"/>
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
    <LinearGradientBrush x:Name="TurnedOffLightGradiantColorName" x:Key="TurnedOffLightGradiantColor" StartPoint="0,0.5" EndPoint="1,0.5">
        <LinearGradientBrush.GradientStops>
            <GradientStop Color="LightGray" Offset="0.5"/>
            <GradientStop Color="DarkGray" Offset="1"/>
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
</UserControl.Resources>

The name 'nameScope' does not exist in the current context HomeControlApp.Droid \obj\Debug\80\g\XamlCodeGenerator\LightWidgetUC_9e91f51bbe3d28fd457787006913b69b.g.cs
image

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • Windows
  • Build tasks

Visual Studio

  • 2017 (version: )
  • 2019 (version: )
  • for Mac (version: )

Relevant plugins

  • Resharper (version: )
@NGame1 NGame1 added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Aug 26, 2019
@ghuntley ghuntley added area/code-generation Categorizes an issue or PR as relevant to code generation and removed triage/untriaged Indicates an issue requires triaging or verification labels Aug 29, 2019
@lextm
Copy link

lextm commented May 30, 2020

There is no feasible workaround if controls such as MenuFlyoutItem are used with x:Load. Example,

            <MenuFlyoutItem
                x:Name="SidebarPinItem"
                x:Uid="BaseLayoutItemContextFlyoutPinToSidebar"
                x:Load="False"
                Click="{Binding PinItem_Click}"
                Tag="PinItem_FlyoutItem"
                Text="Pin to sidebar">
                <MenuFlyoutItem.Icon>
                    <SymbolIcon Symbol="Pin" />
                </MenuFlyoutItem.Icon>
            </MenuFlyoutItem>

If we change that to

            <MenuFlyoutItem
                x:Key="SidebarPinItem"
                x:Uid="BaseLayoutItemContextFlyoutPinToSidebar"
                x:Load="False"
                Click="{Binding PinItem_Click}"
                Tag="PinItem_FlyoutItem"
                Text="Pin to sidebar">
                <MenuFlyoutItem.Icon>
                    <SymbolIcon Symbol="Pin" />
                </MenuFlyoutItem.Icon>
            </MenuFlyoutItem>

then Uno XAML code generator works, but UWP will fail with error message,

Error

Element must have x:Name attribute specified since it uses x:Load.
Files_Uno.UWP
E:\files-uwp\Files_Uno\Files_Uno.Shared\UserControls\LayoutModes\GenericFileBrowser.xaml
254

Therefore, this issue must be fixed

@jeromelaban jeromelaban added the project/styling 👔 Categorizes an issue or PR as relevant to element styling label May 31, 2020
@jeromelaban
Copy link
Member

It may be adjusted by #3183.

/cc @davidjohnoliver

@davidjohnoliver
Copy link
Contributor

Yes this works correctly with #1766. I'll add a test for it.

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 kind/bug Something isn't working project/styling 👔 Categorizes an issue or PR as relevant to element styling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants