amwx/FluentAvalonia

CommandBar NRE on PrimaryCommands.Add

Closed this issue · 1 comments

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):

  • OS: All
  • FluentAvalonia Version [e.g. 1.0.0, or latest]: 2.0.5
  • Avalonia Version: 11.0.6

Additional context
Add any other context about the problem here.

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>