我正在开发WP8应用程序。我需要在菜单页面中添加应用程序栏。
使用以下代码,我添加了应用栏。
但是当存在应用程序条形码时,按钮图像会隐藏。
告诉我我在哪里弄错了。如何解决呢?
应用栏代码
public MainPage()
{
InitializeComponent();
BuildLocalizedApplicationBar();
}
private void BuildLocalizedApplicationBar()
{
ApplicationBar = new ApplicationBar();
ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
appBarButton.Text = AppResources.AppBarButtonText;
ApplicationBar.Buttons.Add(appBarButton);
ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
ApplicationBar.MenuItems.Add(appBarMenuItem);
}
XAML代码
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
</StackPanel>
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="10,0,14,0">
<Button x:Name="Stay" BorderThickness="0" Width="160" HorizontalAlignment="Left" Margin="0,128,0,427">
<Image Name="stayimg" Source="Assets/Images/Icons/stay_up.png" Stretch="Uniform" Height="139" Width="133"></Image>
</Button>
<Button x:Name="Eat" BorderThickness="0" Width="155" HorizontalAlignment="Left" Margin="165,128,0,427">
<Image Name="Eatimg" Source="Assets/Images/Icons/eat_up.png" Stretch="Uniform" Height="139" Width="133"></Image>
</Button>
</Grid>
</Grid>
没有应用条形码输出:-
带有应用条形码:
问题是如何定义图像及其边距。我必须说我不太清楚为什么会发生这种情况,但是问题可能是,在xaml中为整个页面定义边距,但是当您创建AppBar时,它会从底部开始占用72个像素(这可能是图像的值切除一部分)。尝试以下操作-无需留意底边利润:
<Button x:Name="Stay" BorderThickness="0" Width="160" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,128,0,0">
<Image Name="stayimg" Source="Resources/firstImage.png" Stretch="Uniform" Height="139" Width="133"></Image>
</Button>
我也建议不要将“保证金”用于您商品的“全球”定位-它会在很多地方(不同的电话(分辨率)等等)造成问题。而是使用更多的行/列,并按百分比定义其高度/宽度(例如“ 2 *”)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句