我想在Windows Phone 8.1应用栏的次要部分添加自定义控件,例如滑块或按钮,就像相机应用程序中应用栏中的那个一样。 有什么办法可以做到吗?
看起来,我的解决方案只适用于设计师,在尝试了另一个解决方案后,也只在设计师中工作。因此,我得出结论:除了默认按钮之外,无法将任何其他内容放入命令栏,我的尝试如下:
我尝试将这个样式应用到AppbarButton上,按钮在设计师中变成了滑块,但在手机上,样式被覆盖了。
<Style x:Key="ButtonStyle1" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="{ThemeResource PhoneForegroundBrush}"/>
<Setter Property="Foreground" Value="{ThemeResource PhoneForegroundBrush}"/>
<Setter Property="BorderThickness" Value="{ThemeResource PhoneBorderThickness}"/>
<Setter Property="FontFamily" Value="{ThemeResource PhoneFontFamilyNormal}"/>
<Setter Property="FontWeight" Value="{ThemeResource PhoneButtonFontWeight}"/>
<Setter Property="FontSize" Value="{ThemeResource TextStyleLargeFontSize}"/>
<Setter Property="Padding" Value="9.5,0"/>
<Setter Property="MinHeight" Value="{ThemeResource PhoneButtonMinHeight}"/>
<Setter Property="MinWidth" Value="{ThemeResource PhoneButtonMinWidth}"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid x:Name="Grid" Background="Transparent">
<Slider ValueChanged="RangeBase_OnValueChanged" Width="100" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
public sealed class CommandBarSlider : Slider, ICommandBarElement
{
public CommandBarSlider()
{
this.DefaultStyleKey = typeof(Slider);
}
public bool IsCompact { get; set; }
}