我在几个页面中使用了 CommandBar。我注意到我在这部分代码中重复了自己:
<CommandBar x:Name="MyCommandBar">
<CommandBar.Content>
<TextBlock Text="{Binding MyTitle}"/>
</CommandBar.Content>
</CommandBar>
我试图创建一个这样的自定义控件,并buttons
根据页面添加新的控件:
<UserControl
x:Class="TutorialManager.UWP.Views.Controls.MainCommandBarControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<CommandBar >
<CommandBar.Content>
<TextBlock Text="{Binding MyTitle}"/>
</CommandBar.Content>
</CommandBar>
</UserControl>
问题是,例如,当我在此自定义控件中添加一个新按钮时,它与第一个按钮重叠。
有一些解决方案吗?
--编辑 1 --
第一个解决方案看起来不错,但是当我添加一个按钮时,它会移到底部:
<controls:CustomCommandBarControl Title="{Binding TituloPagina}" Foreground="WhiteSmoke">
<AppBarButton Icon="Accept" Label="Save" Foreground="White" />
</controls:CustomCommandBarControl>
--编辑 2 --
看起来更好,但不幸的是我仍然有一些问题。
- 我添加的新按钮与按钮不对齐
more
(甚至设置属性) - 新按钮始终显示其标签。
More
按钮在前后导航时隐藏。- 看起来我
Custom Bar
从以前导航的栏中继承了一些属性