【发布时间】:2017-09-19 20:25:16
【问题描述】:
我在几个页面中使用了 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继承了以前导航栏中的一些属性
【问题讨论】:
标签: uwp xamarin.uwp