I’m afraid I’m missing something simple here, but I’m trying to put multiple buttons in my app bar.
here’s the code for the initial app bar
<common:LayoutAwarePage.TopAppBar>
<AppBar HorizontalAlignment="Left">
<Button x:Name="resetButton" Content="Reset" HorizontalAlignment="Left" VerticalAlignment="Stretch" Click="resetButton_Click" />
</AppBar>
</common:LayoutAwarePage.TopAppBar>
Now this code works, but I want to add a second button.
I thought that this would be fairly simple to do, I attempted:
<common:LayoutAwarePage.TopAppBar>
<AppBar HorizontalAlignment="Left"> <!-- line 19 -->
<Button x:Name="resetButton" Content="Reset" HorizontalAlignment="Left" VerticalAlignment="Stretch" Click="resetButton_Click" />
<Button x:Name="newButton" Content="NewButton" /> <!-- line 21 -->
</AppBar>
</common:LayoutAwarePage.TopAppBar>
but I get the following errors:
The property "Content" can only be set once. (line 19)
The property "Content" can only be set once. (line 21)
Duplication assignment to the 'Content' property of the 'AppBar' object (line 21)
I think there might perhaps be something to the AppBar control that I’m missing. How do i put a second button in it?
Simply put everything in a
StackPanelinAppBarFor better control, you could use a
Gridwhich will allow you to have content on both sides: