CommandBar NRE on PrimaryCommands.Add
Closed this issue · 1 comments
workgroupengineering commented
Describe the bug
Throwed NRE add PrimaryCommands.Add.
Steps
-
Add following xaml at your view
<ui:CommandBar x:Name="MyBar" HorizontalAlignment="Right" Grid.Column="4"/>
-
On code-behind add code like this:
void Button_Click(object sender, EventArgs e) { MyBar.PrimaryCommands.Add(new CommandBarButton(){ Label="Test"}); }
-
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.
workgroupengineering commented
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>