amwx / FluentAvalonia

Control library focused on fluent design and bringing more WinUI controls into Avalonia
MIT License
1.05k stars 97 forks source link

CommandBar NRE on PrimaryCommands.Add #512

Closed workgroupengineering closed 9 months ago

workgroupengineering commented 10 months ago

Describe the bug Throwed NRE add PrimaryCommands.Add.

Steps

  1. Add following xaml at your view

           <ui:CommandBar x:Name="MyBar"
                     HorizontalAlignment="Right"
                     Grid.Column="4"/>
  2. On code-behind add code like this:

         void Button_Click(object sender, EventArgs e)
         {
             MyBar.PrimaryCommands.Add(new CommandBarButton(){ Label="Test"});
         }
  3. On Click button NRE is throw

Screenshots If applicable, add screenshots to help explain your problem.

Desktop/Platform (please complete the following information):

Additional context Add any other context about the problem here.

workgroupengineering commented 10 months ago

Workaround

<ui:CommandBar x:Name="MyBar"
                HorizontalAlignment="Right"
                Grid.Column="4">
        <ui:CommandBar.PrimaryCommands>
          <ui:CommandBarButton/>
        </ui:CommandBar.PrimaryCommands>
        <ui:CommandBar.SecondaryCommands>
          <ui:CommandBarButton/>
        </ui:CommandBar.SecondaryCommands>
</ui:CommandBar>