1
在其代表LayoutAwarePage我xy.xaml文件,我有這樣的兩個元素重用元素(贏商店應用)
<StackPanel x:Name="LeftCommands" Orientation="Horizontal" Grid.Column="2" Margin="0,0,100,0" HorizontalAlignment="Right">
<Button x:Name="BragButton" HorizontalAlignment="Left"/>
</StackPanel>
和
<Page.TopAppBar>
<AppBar x:Name="PageAppBar" Padding="10,0,10,0" Height="120" Opacity="0.98">
<ItemsControl x:Name="groupTopMenuBar" Margin="116,0,40,0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0,0,0,0">
<Button Click="UpperMenu_Click"
Style="{StaticResource TextPrimaryButtonStyle}"
Height="Auto" Margin="20,0,20,0"
CommandParameter="{Binding Group.MenuItemID}">
<StackPanel>
<Image Source="{Binding Group.IconURL}" Width="40"
Height="40" VerticalAlignment="Top" Stretch="UniformToFill" />
<TextBlock Text="{Binding Group.Name}" HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}"
Style="{StaticResource TitleTextStyle}" FontSize="16" />
</StackPanel>
</Button>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</AppBar>
</Page.TopAppBar>
我需要使用這些元素我的應用程序的每一頁,我不想在應用程序的每個.xaml文件中寫這段代碼,所以我想問問是否有任何方法如何做到這一點。
謝謝。