2016-03-19 16 views
0

Şu anda Windows 10'da çalışıyorum ve AppBar ve Command Bar denetimleri üzerinde çalışıyorum. İçerisinde bar düğmesi içeren bir commandBar ekledim. Şimdi sorun, hem commandBar hem de AppBar için daha fazla simge gösteriyor. Lütfen bunu nasıl kaldırabilirim?Windows 10'da uygulama çubuğu nasıl kaldırılır?

Benim Kod

CommandBar commandBar = new CommandBar(); 
if (this.BottomAppBar == null) 
{ 
     this.BottomAppBar = new AppBar(); 
     this.BottomAppBar.IsOpen = true; 
     this.BottomAppBar.IsSticky = true; 
} 

commandBar.PrimaryCommands.Clear(); 
commandBar.IsSticky = true; 
commandBar.IsOpen = true; 
commandBar.ClosedDisplayMode = AppBarClosedDisplayMode.Compact; 
AppBarButton appBarButton = new AppBarButton(); 
appBarButton.Foreground = MCSExtensions.GetColorFromHex(foreground_color); 
appBarButton.Icon = new BitmapIcon() { UriSource = new Uri("ms-appx:///Images/submit.png", UriKind.Absolute) }; 
appBarButton.Label = formButton.B_NAME; 

commandBar.PrimaryCommands.Add(appBarButton); 
this.BottomAppBar.Content=commandBar; 

altına Commandbar değil gri kısmıdır yan çubuğunu bırakılır Ne gerçekten istediğiniz yukarıdaki oluşturuyor aşağıdaki çıkış

enter image description here

olduğunu. Birisi yanlış yaptığım şeyi önerebilir mi? Ayrıca CommmandBar'ı ızgaraya eklemeyi denedim ama hiç görüntülenmedi.

Güncelleme ben de aşağıdaki ancak uygun sonuçlar vermediğinin olarak AppBar bir StackPanel ekleyerek çalıştı

CommandBar commandBar=new CommmandBar(); 
commandBar.IsOpen=true; 
commandBar.IsSticky=true; 
commandBar.ClosedDisplayMode=AppBarClosedDisplatMode.Compact; 
AppBarButton appBarButton = new AppBarButton(); 
appBarButton.Foreground = MCSExtensions.GetColorFromHex(foreground_color); 
appBarButton.Icon = new BitmapIcon() { UriSource = new Uri("ms-appx:///Images/submit.png", UriKind.Absolute) }; 
appBarButton.Label = formButton.B_NAME; 

commandBar.PrimaryCommands.Add(appBarButton); 
pageLayoutRootGrid.Children.Add(commandBar); 

. xaml için

if (this.BottomAppBar == null) 
{ 
     this.BottomAppBar = new AppBar(); 
     this.BottomAppBar.IsOpen = true; 
     this.BottomAppBar.IsSticky = true; 
} 
StackPanel appBarPanel=new StackPanel(); 
appBarPanel.Orientation=Orientation.Horizontal;   
AppBarButton appBarButton = new AppBarButton(); 
appBarButton.Foreground = MCSExtensions.GetColorFromHex(foreground_color); 
appBarButton.Icon = new BitmapIcon() { UriSource = new Uri("ms-appx:///Images/submit.png", UriKind.Absolute) }; 
appBarButton.Label = formButton.B_NAME; 

appBarPanel.Children.Add(appBarButton); 
this.BottomAppBar.Content=appBarPanel; 

cevap

2

:

<Page.BottomAppBar> 
    <CommandBar> 
     <CommandBar.PrimaryCommands> 
      <AppBarButton Icon="Accept"/> 
     </CommandBar.PrimaryCommands> 
    </CommandBar> 
</Page.BottomAppBar> 

bu satırda, UI haberci olun: sen benim xaml gördüğünüz gibi

this.BottomAppBar = new AppBar();

,

BottomAppBar içeride sadece 1 CommandBar oluşturmak

Düzenleme: Kod kullanmak isterseniz şunu kullanın:

var commandBar = new CommandBar(); 
commandBar.PrimaryCommands.Add(new AppBarButton() { Label = "test" }); 
commandBar.VerticalAlignment = VerticalAlignment.Bottom; 
this.root.Children.Add(commandBar); 

GÜNCELLEME

Tam xaml kodu:

<Page 
    x:Class="CommandBarSample.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="using:CommandBarSample" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"> 

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" x:Name="root"> 

    </Grid> 
</Page> 

arkasında kod:

public sealed partial class MainPage : Page 
    { 
     public MainPage() 
     { 
      this.InitializeComponent(); 



      var commandBar = new CommandBar(); 
      commandBar.VerticalAlignment = VerticalAlignment.Bottom; 
      var appBarButton = new AppBarButton() { Icon = new SymbolIcon(Symbol.Accept), Label = "Accept" }; 
      commandBar.PrimaryCommands.Add(appBarButton); 

      root.Children.Add(commandBar); 
     } 
    } 
+0

Ama dinamik benim söz konusu değildir eklenen neyi gibi CommandBar oluşturmak istiyorum Xaml –

+0

kullanarak dinamik olarak oluşturmak için kod örneği ekledim – thang2410199

+0

Kök anlamına geliyor Sayfa doğru? –

İlgili konular